电子邮件-PHPMailer SMTP配置

在过去的2个小时里,我一直在网上寻找是否有其他人遇到此问题,而且看来还有很多问题,机器人没有任何答案对我有用.

SMTP -> FROM SERVER:220 mx.google.com ESMTP vq7sm928004oeb.13 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [50.57.114.141] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250 ENHANCEDSTATUSCODES 
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS 
SMTP -> FROM SERVER: 250-mx.google.com at your service, [50.57.114.141] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250 ENHANCEDSTATUSCODES 
SMTP -> FROM SERVER:530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 vq7sm928004oeb.13 
SMTP -> ERROR: MAIL not accepted from server: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 vq7sm928004oeb.13 
The following From address failed: my@email.com

$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMPTAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->Port = 587;
$mail->Username = "my@email.com";
$mail->Password = "password";

我已经为PHPMailer尝试了几乎所有设置,但无法弄清楚到底出了什么问题,我需要注意任何服务器设置吗?

我也尝试了普通的php mail()函数,但这也不发送邮件,尽管使用Drupal表单时它只是发送电子邮件.

解决方法:

首先,您必须配置正确的服务器以发送电子邮件(请参阅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

在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";
上一篇:使用PHPMailer文件附件


下一篇:PHPmailer – 多次发送电子邮件