使用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;