PHPMailer SMTP configuration

ぃ、小莉子 提交于 2019-12-01 12:04:09
kingmo

For first you must configure the correct server to send emails (see at gmail.com):

SMTP server address: smtp.gmail.com
SMTP user name: Your full Gmail address (e.g. example@gmail.com)
SMTP password: Your Gmail password
SMTP port: 465 or 587
SMTP TLS/SSL required: yes

In PHPMailer:

$mail->SMTPAuth = true; // There was a syntax error here (SMPTAuth)
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->Port = 465;
$mail->Username = "YOU@gmail.com";
$mail->Password = "YOUR_GMAIL_password";

My problem was that I use the 2-step verification. So I had to remember to go to Authorised Access for my Google Account & then assign a Application-specific passwords for the domain that I'm using to send the mail.

Just noticed I typed SMTP wrong in this line $mail->SMPTAuth = true;, correcting this solved my problem.

Setting up mail in php can be quite hard. have you tried using port=25?

The suggested port+protocol-combination seems wrong to me, because it's different to the official phpMailer-wiki:

Don't mix up these modes; ssl on port 587 or tls on port 465 will not work.

In PHPMailer:

$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->Port = 587; //use port 465 when using SMPTSecure = 'ssl'
$mail->Username = "YOU@gmail.com";
$mail->Password = "YOUR_GMAIL_password";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!