我有PHPMailer的以下配置,它在我的localhost机器上完美运行,但不会在生产中发送电子邮件:
//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帐户发送电子邮件是正确配置的(之前有效),我的登录凭据也是正确的。
有什么想法吗?
答案 0 :(得分:1)
您的电子邮件很可能无法投放,因为.co.cc
域名与垃圾邮件和非合法网站相关联; Google has banned all .co.cc
domains from its index
因此,他们阻止或严重过滤来自这些域的电子邮件也是有道理的。
考虑使用普通域名,例如以.com
结尾的域名。