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.