2011-09-21 168 views
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 
} 

我会的帮助非常感激。

+2

你为什么要手动执行此操作,而不仅仅是调用'mail()'? –

+0

因为验证电子邮件。我工作localhost。然后只需步入服务器。 – user628298

+0

您可以设置PHP的mail()函数以使用SMTP验证。 – ceejayoz

回答

0

尝试this。这是mail()功能的替代选择。