doukanhua0752 2011-09-21 13:10
浏览 22

SMTP不发送HTML消息

Good morning,

I'm trying to send SMTP mail with HTML message. But not this gets the message.

So I did a test. Text messages sent successfully. Html message and sends it with little success.

And server problem that is not accepting my post html?

Server Response:

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

Response connection.:

 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 

My code:

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."> 
";
      $this->co .= "From: $my_email <$my_email> 
";
      $this->co .= "Subject: ".$sub." 
";
      $this->co .= "$body_m 
";
      $this->co .= "MIME-Version: 1.0 
";
      $this->co .= "Content-Type: text/html; 
";
      $this->co .= "charset=\"iso-8859-1\" 
";
      return  $this->co;
}

private function socket(){
            return fputs($this->conxe, $string."
"); //fwrite
}

I would be very grateful for the help.

  • 写回答

1条回答 默认 最新

  • dongtan8122 2011-09-21 13:28
    关注

    Try this. It's an alternatieve to the mail() function.

    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭