SMTP不发送HTML消息

时间:2011-09-21 13:10:03

标签: php html smtp fputs

早上好,

我正在尝试使用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
}

我非常感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

试试this。它是mail()函数的替代品。