PHP使用phpmailer发送邮件?


<?php

//定义一个mail发送函数
function sendMail($address,$title,$message){


 //导入mail类文件
require("./PHPMailer/class.phpmailer.php");

//创建mail对象
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->Host="smtp.163.com";
$mail->SMTPAuth =true;
$mail->Username= "[email protected]";
$mail->Password= "x x x x x x";
$mail->From    = "[email protected]";
$mail->FromName= "乐分享weshare";
$mail->AddAddress($address);
$mail->IsHTML(true);
$mail->Subject=$title;
$mail->Body   =$message;

if(!$mail->Send()){


 return true;

}else{


 return false;

}

}
sendMail("[email protected]","测试","... ;
?>
PHP使用phpmailer发送邮件,提示没有通过验证(SMTP Error: Could not authenticate. ),注释掉验证代码之后,又显示The following From address failed:?

php phpmailer

Khoomei 9 years, 2 months ago

class.smtp.php没require啊
看下环境的log,并且提高下phpmailer的debug等级看下

l0T0l answered 9 years, 2 months ago

邮箱需要开启SMTP服务,可以在邮箱中设置~ 163邮箱应该会单独分配SMTP的密码

(PS: 使用QQ邮箱发送要注意端口号不是默认的25!!!)

kula321 answered 9 years, 2 months ago

Your Answer