0
早上好,SMTP不發送HTML郵件
我試圖用HTML郵件發送SMTP郵件。但是,這不會得到消息。
所以我做了一個測試。短信發送成功。 Html消息併發送一點點成功。
和服務器問題,不接受我的文章HTML?
服務器響應:
220 HOST ESMTP
250-HOST
250-PIPELINING
250-SIZE 40960000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH = PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
響應連接:
220 HOST ESMTP
250-HOST
250-PIPELINING
250-SIZE 40960000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250 8BITMIME
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.7.0 Authentication successful
250 2.1.0 Ok
250 2.1.5 Ok
354 End data with .
250 2.0.0 Ok: queued as 3B74C7E40BA 221 2.0.0 Bye
我的代碼:
private function conx(){
$this->conxe = fsockopen($smtp_serve, $port, $errno, $errstr, 30) or die('Erro log: smtp 12');
return true;
}
private function send_email($email_send, $sub, $body_m){
$this->socket("EHLO ".$smtp_serve."");
$this->socket("AUTH LOGIN");
$this->socket(base64_encode($user));
$this->socket(base64_encode($pass));
$this->socket("MAIL FROM:" .$smtp_in);
$this->socket("RCPT TO:" .$email_send);
$this->socket("DATA");
$this->socket($this->body($email_send, $sub, $body_m));
$this->socket(".");
$this->socket("QUIT");
fclose($this->socket);
}
private function body($email_send, $sub, $body_m){
$this->co = "To: ".$email_send." <".$email_send."> \r\n";
$this->co .= "From: $my_email <$my_email> \r\n";
$this->co .= "Subject: ".$sub." \r\n";
$this->co .= "$body_m \r\n";
$this->co .= "MIME-Version: 1.0 \r\n";
$this->co .= "Content-Type: text/html; \r\n";
$this->co .= "charset=\"iso-8859-1\" \r\n";
return $this->co;
}
private function socket(){
return fputs($this->conxe, $string."\r\n"); //fwrite
}
我會的幫助非常感激。
你爲什麼要手動執行此操作,而不僅僅是調用'mail()'? –
因爲驗證電子郵件。我工作localhost。然後只需步入服務器。 – user628298
您可以設置PHP的mail()函數以使用SMTP驗證。 – ceejayoz