>백엔드 개발 >PHP 튜토리얼 > 用socket发邮件 有个有关问题

用socket发邮件 有个有关问题

WBOY
WBOY원래의
2016-06-13 12:56:391063검색

用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>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.