PHP使用phpmailer发送邮件?

WBOY
Release: 2016-06-06 20:26:33
Original
1144 people have browsed it

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

<code>//导入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;
</code>
Copy after login
Copy after login

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

<code> return true;</code>
Copy after login
Copy after login

}else{

<code> return false;</code>
Copy after login
Copy after login

}

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

回复内容:

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

<code>//导入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;
</code>
Copy after login
Copy after login

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

<code> return true;</code>
Copy after login
Copy after login

}else{

<code> return false;</code>
Copy after login
Copy after login

}

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

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

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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
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!