我使用的Symfony + SwiftMailer和SwiftMailer得到以下錯誤:爲什麼SwiftMailer拋出「內部服務器錯誤」?
500 | Internal Server Error | Swift_TransportException
Expected response code 220 but got code "", with message ""
,不能找出原因。我使用hMailServer我的本地機器上,並且有安裝我的factories.yml文件的文件(如我使用的Symfony)如下:
mailer:
class: sfMailer
param:
logging: %SF_LOGGING_ENABLED%
charset: %SF_CHARSET%
delivery_strategy: realtime
transport:
class: Swift_SmtpTransport
param:
host: splodge.loc
port: 25
encryption: ~
username: ~
password: ~
我用下面的代碼來發送:
$message = $this->getMailer()->compose(
'[email protected]',
'[email protected]',
'Reset Password',
'Message'
);
$result = $this->getMailer()->send($message);
有沒有人有過這樣的問題?
我發現有時和非常隨機的發送過程中,但每隔一段時間,我都會收到上述錯誤消息。因此,不斷刷新發送郵件的頁面,不可預知地失敗,並且隨着代碼有時起作用,很難弄清楚什麼是錯誤的。
任何幫助將不勝感激!
進一步的調查表明,SMTP服務器併發送[220本地主機ESMTP],但考慮看看hMailServer登錄後,我發現了以下內容:
"TCPIP" 5232 "2010-06-16 11:40:54.043" "TCPConnection - Posting AcceptEx on 0.0.0.0:25"
"DEBUG" 5232 "2010-06-16 11:40:54.043" "Creating session 51"
"SMTPD" 5232 51 "2010-06-16 11:40:54.043" "127.0.0.1" "SENT: 220 localhost ESMTP"
"DEBUG" 5296 "2010-06-16 11:40:54.199" "The read operation failed. Bytes transferred: 0 Remote IP: 127.0.0.1, Session: 51, Code: 10054, Message: An existing connection was forcibly closed by the remote host"
"DEBUG" 5296 "2010-06-16 11:40:54.199" "Ending session 51"
難道說SwiftMailer是HELO/EHLOing太早了,這只是一個時間問題?我可以延遲HELO傳輸嗎?
的上等原木,當事情實際上發送如下所示:
"TCPIP" 5232 "2010-06-16 11:42:21.278" "TCPConnection - Posting AcceptEx on 0.0.0.0:25"
"DEBUG" 5232 "2010-06-16 11:42:21.294" "Creating session 54"
"SMTPD" 5232 54 "2010-06-16 11:42:21.294" "127.0.0.1" "SENT: 220 localhost ESMTP"
"SMTPD" 5224 54 "2010-06-16 11:42:21.294" "127.0.0.1" "RECEIVED: EHLO splodge.loc"
所以它必須與HELO/EHLO確認的事情。請指教! :)
問題可能在於您的主機。你爲什麼不嘗試Gmail,看看你是否遇到同樣的問題。 – Dziamid 2011-06-11 13:06:57