PHP接收数据后发送邮件,用phpmailer类开发邮件发送,执行成功,但接收不到邮件...

邮件发送过程中,错误可能有很多,文件未包裹的空白字符、邮箱平台都可能导致程序莫名崩溃,我的建议是不要用QQ邮箱,试一下126邮箱。

这是我之前测试通过的代码:

function sendMail($address,$title,$content){

require("./PHPMailer/class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP

$mail->Host = "smtp.126.com"; // specify main and backup server

$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->Username = "roadcover@126.com"; // SMTP username

$mail->Password = "wangyi126"; // SMTP password

$mail->From = "roadcover@126.com";

$mail->FromName = "Mailer";

$mail->AddAddress($address); // name is optional

//$mail->AddReplyTo("info@example.com", "Information");

//$mail->WordWrap = 50; // set word wrap to 50 characters

//$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments

//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name

$mail->IsHTML(true); // set email format to HTML

$mail->CharSet='UTF-8';

$mail->Subject = $title;

$mail->Body = $content;

//$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())

{

echo "Message could not be sent.

";

echo "Mailer Error: " . $mail->ErrorInfo;

exit;

}

echo "Message has been sent";

}

sendMail("roadcover@126.com","测试",'hello,world');

?>

你简单改一下代码即可,仅注意:$mail->Password 的密码不是指邮箱登陆密码,是指登陆后STMP认证密码,如果对你有帮助,请为我点个赞:),谢谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值