PHP使用phpmailer发送邮件?
迷茫
迷茫 2017-04-10 16:10:06
0
2
375

//定义一个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= "18501773419@163.com"; $mail->Password= "x x x x x x"; $mail->From = "18501773419@163.com"; $mail->FromName= "乐分享weshare"; $mail->AddAddress($address); $mail->IsHTML(true); $mail->Subject=$title; $mail->Body =$message;

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

return true;

}else{

return false;

}

}
sendMail("18501773419@163.com","测试","你好我是peace");
?>
PHP使用phpmailer发送邮件,提示没有通过验证(SMTP Error: Could not authenticate. ),注释掉验证代码之后,又显示The following From address failed:?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (2)
黄舟

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

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

    PHPzhong

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

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!