關於smtp發郵件,誰能幫忙看看 503 Error: need EHLO and AUTH first
Resolving SMTP server domain "smtp.qq.com"...
Connecting to host address "119.147.74.45" port 25...
Connected to SMTP server "smtp.qq.com".
S 220 esmtp4.qq.com Esmtp QQ Mail Server
C EHLO localhost
S 250-esmtp4.qq.com
S 250-PIPELINING
S 250-SIZE 52428800
S 250-AUTH LOGIN
S 250-AUTH=LOGIN
S 250 8BITMIME
C MAIL FROM:<[email protected]>
C RCPT TO:<[email protected]>
C DATA
S 503 Error: need EHLO and AUTH first !
Disconnected.
Cound not send the message to [email protected] Error: 503 Error: need EHLO and AUTH first !
------解決方案--------------------
發送郵件前需要登陸
你有沒有發登陸資訊給smtp.qq.com伺服器?
------解決方案--------------------
1) 檢查你的QQ郵箱的POP/SMTP功能有沒有開啟?
2) 有可能你的程式多次登入,被QQ郵箱當作惡意登入給拒絕了,換其他郵箱發送試試看。
3) 貼出你的代碼,要不然別人不知道怎麼幫你檢查
------解決方案--------------------
很可能是你的qq郵箱的設定錯誤..看看開通了pop3和smtp服務.
------解決方案--------------------
need EHLO and AUTH first !
這個不是說得很清楚了嗎?
要先打招呼握手,並請求登陸。
PHP code
if(!$fp=fsockopen($this->smtp['host'],$this->smtp['port'],$errno,$errstr)){ $this->message[]="串連郵件伺服器失敗,請檢查:\r\n1、伺服器位址和連接埠是否設定正確!\r\n2、網路是否通暢!"; return false; } if(strncmp(fgets($fp,512),'220',3)!=0){ $this->message[]="串連郵件伺服器失敗,請檢查:\r\n1、伺服器位址和連接埠是否設定正確!\r\n2、網路是否通暢!"; return false; } if($this->smtp['auth']){ fwrite($fp,"EHLO ".$this->smtp['posthost']."\r\n"); while($rt=strtolower(fgets($fp,512))){ if(strpos($rt,"-")!==3 || empty($rt)){ break; }elseif(strpos($rt,"2")!==0){ $this->message="與伺服器招呼握手時錯誤"; return false; } } fwrite($fp, "AUTH LOGIN\r\n"); if(strncmp(fgets($fp,512),'334',3)!=0){ $this->message="提示伺服器要登陸驗證時錯誤"; return false; } fwrite($fp, base64_encode($this->smtp['user'])."\r\n"); if(strncmp(fgets($fp,512),'334',3)!=0){ $this->message="SMTP AUTH LOGIN 驗證 使用者名稱 錯誤!"; return false; } fwrite($fp, base64_encode($this->smtp['pass'])."\r\n"); if(strncmp(fgets($fp,512),'235',3)!=0){ $this->message="SMTP AUTH LOGIN 驗證 密碼 錯誤!"; return false; } } else{ fwrite($fp, "HELO ".$this->smtp['posthost']."\r\n"); } $from = $this->smtp['from']; $from = preg_replace("/.*\<(.+?)\>.*/", "\\1", $from); fwrite($fp, "MAIL FROM: <$from>\r\n"); if(strncmp(fgets($fp,512),'250',3)!=0){ $this->message="發信人地址錯誤!"; return false; } fwrite($fp, "RCPT TO: <$toemail>\r\n"); if(strncmp(fgets($fp,512),'250',3)!=0){ $this->message="收信人地址錯誤!"; return false; } fwrite($fp, "DATA\r\n"); if(strncmp(fgets($fp,512),'354',3)!=0){ $this->message="郵件資料發送失敗!"; return false; } $msg = "Date: ".date("r")."\r\n"; $msg .= "Subject: $send_subject\r\n"; $msg .= "$additional\r\n"; $msg .= "$send_message\r\n.\r\n"; fwrite($fp, $msg); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250){ $this->message="串連郵件伺服器失敗,請檢查:\r\n1、伺服器位址和連接埠是否設定正確!\r\n2、網路是否通暢!"; return false; } fwrite($fp, "QUIT\r\n"); fclose($fp); return true;