我正在使用G Suite SMTP中繼服務完成訂單時向客戶發送多封電子郵件的電子商務網站。但是大量這些電子郵件都失敗了。似乎也沒有任何模式 - 有時候所有的電子郵件都會發送,有時候只有一兩次,有時甚至沒有。調試SMTP電子郵件故障 - GSuite
我收到以下錯誤:421, "4.7.0", Try again later, closing connection
。
尋找這裏:https://support.google.com/a/answer/3726730?hl=en並沒有真正幫助我調試,或找出爲什麼一些電子郵件失敗。
我使用的PHPMailer類(https://sourceforge.net/projects/phpmailer/)
這個問題似乎在第一握手失敗發生:
function Hello($host="") {
$this->error = null; # so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Hello() without being connected");
return false;
}
# if a hostname for the HELO was not specified determine
# a suitable one to send
if(empty($host)) {
# we need to determine some sort of appopiate default
# to send to the server
$host = "localhost";
}
// Send extended hello first (RFC 2821)
//If this fails then the second attempt will always fail
if(!$this->SendHello("EHLO", $host))
{
//when this fails it generates the try again later error
if(!$this->SendHello("HELO", $host))
return false;
}
return true;
}
那麼,什麼是調試這個最好的方法?
添加調試記錄器和步驟記錄以確定確切的問題。 –