使用 php 邮件程序通过 Gmail 发送 - SMTP 错误 [英] Use php mailer to send via Gmail - SMTP error

查看:61
本文介绍了使用 php 邮件程序通过 Gmail 发送 - SMTP 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚通过 gsuite/gmail 注册了一个域,以将其用作我的 php 邮件程序的新邮件服务器域.

I just registered a domain via gsuite/gmail to use this as a new mailserver domain for my php mailer.

现在我通读了大多数相关主题并调整了提示,但我仍然收到错误消息:

Now I read through most related topics and adapted the hints, but I still receive the error message:

Message could not be sent.

Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

这是我的代码:

$mail->Subject = "Tutor found for help";    

//From email address and name
$mail->setFrom('frank@xxx.net', 'xxx.net');

$mail->addAddress("$clientmail", "$clientname");
//$mail->addAddress("nachhilfeanfrage@xxx.net", "xxx.net");

$mail->addReplyTo('frank@xxx.net', 'xxx.net');

$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 2;  // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;  // authentication enabled
$mail->SMTPSecure = 'tls'; // secure transfer enabled required for GMail
$mail->SMTPAutoTLS = false;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;    // Port for TLS Gmail
$mail->Username = 'xx';   // SMTP username
$mail->Password = 'xx';     

$mail->isHTML(true);
$mail->CharSet = 'UTF-8';

推荐答案

这可能与 无法通过 PHPMailer 使用 Gmail SMTP 服务器发送电子邮件,出现错误:在端口 587 上提交邮件需要 SMTP AUTH.如何解决?

可能是您不允许在 Gmail 帐户安全仪表板中使用安全性较低的应用.

Probably you didn't allow for less secured apps in Gmail account security dashboard.

这篇关于使用 php 邮件程序通过 Gmail 发送 - SMTP 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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