1.首先下载phpmailer库
链接:https://pan.baidu.com/s/14AW6diRVkmYzmiOBGoyZ4g
提取码:xw1z
2.调用phpmailer并发送邮件的案例
include_once ("phpmailer/class.phpmailer.php");
include_once ("phpmailer/class.smtp.php");
$mail = new PHPMailer(true);
$mail->CharSet = "UTF-8";
$address = $email;
$mail->IsSMTP();
$mail->Host = "smtp.qq.com";
$mail->SMTPAuth = true;
$mail->Username = "admin@bcxw.net";
$mail->Password = "123456";
$mail->Port = 25;
$mail->From = "admin@bcxw.net";
$mail->FromName = "IT学问网";
$mail->AddAddress("$address", "$address");
$mail->IsHTML(true);
$mail->Subject = "IT学问网-邮箱验证";
$mail->Body = "您好!欢迎访问 IT学问网(ITXW.NET) ,您本次获取的验证码是:".$authnum;
if (!$mail->Send()) {
$result["code"]=1;
$result["message"]="邮箱验证码发送失败,请稍后再试!";
}