今天框架的Email Class出現了個奇怪的bug,使用Gmail的Smtp無法發信,出現的錯誤是:
Warning: fsockopen() [function.fsockopen]: SSL: Connection reset by peer in /var/www/email/email.php on line 1423
Warning: fsockopen() [function.fsockopen]: Failed to enable crypto in /var/www/email/email.php on line 1423
Warning: fsockopen() [function.fsockopen]: unable to connect to sslv2://smtp.gmail.com:465 (Unknown error) in /var/www/email/email.php on line 1423
AUTH LOGIN
經過搜索,終於嘗試出了解決方案。
因為Gmail的鏈接是需要通過SSL方式的,這個可以看這個頁面
http://mail.google.com/support/bin/answer.py?hl=cn&answer=13287
當初使用的協議是sslv2,因為SSl不能用
在Google到國外的一個站點時,有人也遇到了同樣的問題。他提出的解決辦法是
當你用Sslv2 465不能發送email時,可以嘗試用Ssl的方式活587端口來解決。
結果是改用SSl取代SSLV2時,email class正常工作了。
附 改前代碼塊(Wrong Code):
if($this->smtp_port == ’465′ )
{
$this->smtp_host=’sslv2://’.$this->smtp_host;
}
附改後代碼塊(Right Code)
if($this->smtp_port == ’465′ || $this->smtp_port == ’587′ )
{
$this->smtp_host=’ssl://’.$this->smtp_host;
}
近期评论