【发布时间】:2020-11-23 13:18:45
【问题描述】:
我刚刚通过 gsuite/gmail 注册了一个域,将其用作我的 php 邮件程序的新邮件服务器域。
现在我阅读了大多数相关主题并调整了提示,但我仍然收到错误消息:
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';
【问题讨论】: