我有以下 PHPMailer 配置,它在我的本地主机上运行良好,但在生产中不发送电子邮件:
//Send a notification email
try {
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = $username;
$mail->Password = $password;
$mail->AddAddress($_POST['username'], $name);
$mail->SetFrom("no-reply@a-domain-setup-in-google-apps.com", "No-Reply");
$mail->Subject = $subject;
$mail->AltBody = $altBody;
$mail->MsgHTML($bodyHTML);
$mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage();
exit;
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
当我将 SMTP 调试设置为等于 时2
,我得到的是:
SMTP -> FROM SERVER:220 mx.google.com ESMTP bo7sm9593967igb.2
SMTP -> FROM SERVER: 250-mx.google.com at your service, [204.93.159.80] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 PIPELINING
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS
SMTP -> FROM SERVER: 250-mx.google.com at your service, [204.93.159.80] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH 250-ENHANCEDSTATUSCODES 250 PIPELINING
SMTP -> FROM SERVER:250 2.1.0 OK bo7sm9593967igb.2
SMTP -> FROM SERVER:250 2.1.5 OK bo7sm9593967igb.2
SMTP -> FROM SERVER:354 Go ahead bo7sm9593967igb.2
SMTP -> FROM SERVER:250 2.0.0 OK 1341071123 bo7sm9593967igb.2
一切看起来都很好,但我不能再发送电子邮件了。
我很肯定我发送电子邮件的 Google Apps 帐户配置正确(就像以前一样),并且我的登录凭据是正确的。
有任何想法吗?