使用SMTP发送邮件(SMTP错误:无法进行身份验证) [英] Sending mails with SMTP (SMTP Error: Could not authenticate)

查看:606
本文介绍了使用SMTP发送邮件(SMTP错误:无法进行身份验证)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHPMailer发送电子邮件,但我总是收到上述错误。



I'm using PHPMailer to send email, but I always get the error above.

include("PHPMAILER/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth   = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port  = 465;
$mail->Mailer= "smtp";
$mail->Username   = "tx@gmail.com";
$mail->Password   >= "password";
$mail->AddReplyTo ("txtmachado03@gmail.com", "Recipient Name");
$mail->From = "txtmachado03@gmail.com";
$mail->FromName = "Sender Name";
$mail->Subject = "Email Subject";
$mail->Body = "Email Content…";
$mail->WordWrap = 50;
$mail->AddAddress ("txtmachado03@gmail.com", "Receiver Name");
$mail->IsHTML (true);
$mail->Send ();





我读过很多教程说我们必须启用php扩展(openssl),但我在ubuntu上找不到它。我也不知道它是否默认安装,因为当我这样做时:



apt-cache search php | egrep ^ php5-



没有出现与ssl相关的任何扩展(但是安装了openssl包)



你能帮我吗?



Many tutorials I read it says that we have to enable the php extension (openssl), but I don't find it on ubuntu. I also do not know if it's installed by default because when I do this:

apt-cache search php|egrep ^php5-

does not appear any extension related to ssl (however openssl package is installed)

Can you please help me ?

推荐答案

mail = new PHPMailer();
mail = new PHPMailer();


mail-> IsSMTP();
mail->IsSMTP();


mail - > SMTPAuth = true;
mail->SMTPAuth = true;


这篇关于使用SMTP发送邮件(SMTP错误:无法进行身份验证)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆