用socket发邮件 有个问题
我看网上的用socket发邮件
基本上都是吧内容让在
Subject :
XXXXXXX 就是这个地方了
.
但是我加了标签之后如div
总是会被转义
那在内容中放张图片进去 直接接收不到了......郁闷
改怎么办了???
代码如下
<br> class aMail{<br> public static $smtp_prot = 25;<br> public static $debug = true;<br> public static $crlf = "\r\n";<br> var $smtp_host;<br> var $login_name;<br> var $password;<br> var $form;<br> var $to;<br> var $err;<br> var $message;<br> var $socket;<br> function __construct($options=""){<br> if($options == "" || !is_array($options)){<br> return false;<br> }<br> foreach($options as $key=>$val){<br> $this->$key = $val;<br> }<br> }<br><br> function sendMail(){ <br> $this->socket = fsockopen($this->smtp_host,self::$smtp_prot);<br> $socket = $this->socket;<br> $crlf = self::$crlf;<br> stream_set_blocking($socket,true);<br> $this->message = fgets($socket,512); <br> echo $this->message;<br> if(!$this->print_messsage("/^220/","connect fail")){<br> return false;<br> }<br><br> fputs($socket,"EHLO 127.0.0.1 ".$crlf);<br> $this->message = fgets($socket, 512); <br> if(!$this->print_messsage("/^2/","EHLO fail")){<br> return false;<br> }<br> <br> fputs($socket,"AUTH LOGIN".$crlf);<br> $this->message = fgets($socket, 512); <br> $this->print_messsage("/^2/","AUTH LOGIN fail");<br> <br> fputs($socket,base64_encode($this->login_name).$crlf);<br> $this->message = fgets($socket, 512); <br> $this->print_messsage("/^2/","login_name fail");<br> <br> fputs($socket,base64_encode($this->password).$crlf);<br> $this->message = fgets($socket, 512); <br> $this->print_messsage("/^2/","password fail"); <br><br> fputs($socket,"MAIL FROM: from.">".$crlf);<br> $this->message = fgets($socket, 512);<br> $this->print_messsage("/^2/","from fail");<br><br> fputs($socket,"RCPT TO: to.">".$crlf);<br> $this->message = fgets($socket, 512);<br> $this->print_messsage("/^334|^2/","to fail");<br> <br> fputs($socket,"DATA".$crlf);<br> $this->message = fgets($socket, 512);<br> $this->print_messsage("/^334|^2/","DATA fail"); <br><br> $html = implode("",array(<br> "To: ".$this->to.$crlf,<br> "From: ".$this->from.$crlf,<br> "Subject: ".$this->subject.$crlf.$crlf,<br> $this->content.$crlf.".".$crlf,<br> ));<br><br> fputs($socket,$html);<br> $this->message = fgets($socket, 512);<br> $this->print_messsage("/^2/","html fail");<br> <br> fputs($socket, "QUIT".$crlf);<br> $this->message=fgets($socket,512);<br> $this->print_messsage("/^2/","QUIT fail");<br> }<br> function print_messsage($reg="",$err=""){<br> $message = $this->message;<br> if(preg_match($reg,$message) $this->err = $err."___".$message."--------------";<br> echo $err."___".$message."--------------<br>";<br> return false;<br> }<br> if(self::$debug){<br> echo $this->message."<br>";<br> }<br> return true;<br> }<br> }<br> $mail_options = array(<br> "smtp_host"=>"smtp.sina.com.cn",<br> "login_name"=>"ycwtt0527",<div class="clear"> </div>