用phpmailer发邮件的时候出现有关问题
时间:2021-07-01 10:21:17
帮助过:9人阅读
用phpmailer发邮件的时候出现问题
require_once('class.phpmailer.php'); //下载的文件必须放在该文件所在目录
$address=$_POST['address'];
echo $address."
";
$mail = new PHPMailer(); //建立邮件发送类
$address = $_POST['address'];
$mail->IsSMTP(); // 使用SMTP方式发送
$mail->Host = "smtp.163.com"; // 您的企业邮局域名
$mail->SMTPAuth = true; // 启用SMTP验证功能
$mail->Username = "*********@163.com"; // 邮局用户名(请填写完整的email地址)
$mail->Password = "********"; // 邮局密码
$mail->From = "******@163.com"; //邮件发送者email地址
$mail->FromName = "";
$mail->AddAddress("$address", "QQ");//收件人地址,可以替换成任何想要接收邮件的email信箱,
$mail->Subject = "PHPMailer测试邮件"; //邮件标题
$mail->Body = "Hello,这是测试邮件"; //邮件内容
$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加信息,可以省略
if(!$mail->Send())
{
echo "邮件发送失败.
";
echo "错误原因: " . $mail->ErrorInfo;
exit;
}
echo "邮件发送成功";
?>
Warning: preg_match() [function.preg-match]: Compilation failed: reference to non-existent subpattern at offset 626 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\class.phpmailer.php on line 667
邮件发送失败.
错误原因: You must provide at least one recipient email address.
分享到:
------解决方案--------------------你的163账号是否是一个有效的账号。试试QQ邮箱能发吗
$mail->AddAddress($address); //改成这样试试