An error occurred while sending emails via socket.

Source: Internet
Author: User
There is a problem with sending emails via socket. I think socket sending emails on the internet is basically the same as sending content to Subject & nbsp;: XXXXXXX & nbsp; that's where it is. however, after I add a tag, div & nbsp; will always be escaped, so I can put an image in the content and cannot directly receive it .... an error occurred while sending emails via socket.
I think socket-based mails are sent on the Internet.
Basically, let's
Subject:

XXXXXXX is here.
.

But after I add tags
Will always be escaped

The image in the content cannot be received directly.
What should I do ???
The code is as follows:


class aMail{
public static $smtp_prot = 25;
public static $debug = true;
public static $crlf  = "\r\n";
var $smtp_host;
var $login_name;
var $password;
var $form;
var $to;
var $err;
var $message;
var $socket;
function __construct($options=""){
if($options == "" || !is_array($options)){
return false;
}
foreach($options as $key=>$val){
$this->$key = $val;
}
}

function sendMail(){ 
$this->socket = fsockopen($this->smtp_host,self::$smtp_prot);
$socket = $this->socket;
$crlf   = self::$crlf;
stream_set_blocking($socket,true);
$this->message = fgets($socket,512);
echo $this->message;
if(!$this->print_messsage("/^220/","connect fail")){
return false;
}

fputs($socket,"EHLO 127.0.0.1 ".$crlf);
$this->message = fgets($socket, 512);
if(!$this->print_messsage("/^2/","EHLO fail")){
return false;
}

fputs($socket,"AUTH LOGIN".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","AUTH LOGIN fail");

fputs($socket,base64_encode($this->login_name).$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","login_name fail");

fputs($socket,base64_encode($this->password).$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","password fail");

fputs($socket,"MAIL FROM: <".$this->from.">".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","from fail");

fputs($socket,"RCPT TO: <".$this->to.">".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^334|^2/","to fail");

fputs($socket,"DATA".$crlf);
$this->message = fgets($socket, 512);
$this->print_messsage("/^334|^2/","DATA fail");

$html = implode("",array(
"To: ".$this->to.$crlf,
"From: ".$this->from.$crlf,
"Subject: ".$this->subject.$crlf.$crlf,
$this->content.$crlf.".".$crlf,
));

fputs($socket,$html);
$this->message = fgets($socket, 512);
$this->print_messsage("/^2/","html fail");

fputs($socket, "QUIT".$crlf);
$this->message=fgets($socket,512);
$this->print_messsage("/^2/","QUIT fail");
}
function print_messsage($reg="",$err=""){
$message = $this->message;
if(preg_match($reg,$message)<=0){
$this->err = $err."___".$message."--------------";
echo $err."___".$message."--------------
";
return false;
}
if(self::$debug){
echo $this->message."
";
}
return true;
}
}
$mail_options = array(
"smtp_host"=>"smtp.sina.com.cn",
"login_name"=>"ycwtt0527",

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.