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
}
我将非常感谢您的帮助。
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."> \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
}
I would be very grateful for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这个。它是
mail()
函数的替代函数。Try this. It's an alternatieve to the
mail()
function.