<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[虫虫的blog  SINCE2004]]></title> 
<link>http://www.zhenghe.biz/index.php</link> 
<description><![CDATA[人生幻灯片  -   前半生(身)，不要怕；后半生(身)，不要悔！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[虫虫的blog  SINCE2004]]></copyright>
<item>
<link>http://www.zhenghe.biz/read.php/.htm</link>
<title><![CDATA[收集一个smtp发信的php函数，已经测试 ]]></title> 
<author>网络毛毛虫 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[技术文章]]></category>
<pubDate>Tue, 29 Nov 2005 16:30:43 +0000</pubDate> 
<guid>http://www.zhenghe.biz/read.php/.htm</guid> 
<description>
<![CDATA[ 
	<font face="Courier New">echo send_mail('test@test.com','发信标题','发信内容'); <br /><br /><br />function send_mail($to, $subject = 'No subject', $body) &#123; <br />$loc_host = &quot;#&quot;; //发信计算机名，可随意 <br />$smtp_acc = &quot;#&quot;; //Smtp认证的用户名， <br />$smtp_pass=&quot;password&quot;; //Smtp认证的密码，一般等同pop3密码 <br />$smtp_host=&quot;#&quot;; //SMTP服务器地址，类似 smtp.tom.com <br />$from=&quot;#&quot;; //发信人Email地址，你的发信信箱地址 <br />$headers = &quot;Content-Type: text/plain; charset=\&quot;gb2312\&quot;\r\nContent-Transfer-Encoding: base64&quot;; <br />$lb=&quot;\r\n&quot;; //linebreak <br /><br />$hdr = explode($lb,$headers); //解析后的hdr <br />if($body) &#123;$bdy = preg_replace(&quot;/^\./&quot;,&quot;..&quot;,explode($lb,$body));&#125;//解析后的Body <br /><br />$smtp = array( <br />//1、EHLO，期待返回220或者250 <br />array(&quot;EHLO &quot;.$loc_host.$lb,&quot;220,250&quot;,&quot;HELO error: &quot;), <br />//2、发送Auth Login，期待返回334 <br />array(&quot;AUTH LOGIN&quot;.$lb,&quot;334&quot;,&quot;AUTH error:&quot;), <br />//3、发送经过Base64编码的用户名，期待返回334 <br />array(base64_encode($smtp_acc).$lb,&quot;334&quot;,&quot;AUTHENTIFICATION error : &quot;), <br />//4、发送经过Base64编码的密码，期待返回235 <br />array(base64_encode($smtp_pass).$lb,&quot;235&quot;,&quot;AUTHENTIFICATION error : &quot;)); <br />//5、发送Mail From，期待返回250 <br />$smtp[] = array(&quot;MAIL FROM: &lt;&quot;.$from.&quot;&gt;&quot;.$lb,&quot;250&quot;,&quot;MAIL FROM error: &quot;); <br />//6、发送Rcpt To。期待返回250 <br />$smtp[] = array(&quot;RCPT TO: &lt;&quot;.$to.&quot;&gt;&quot;.$lb,&quot;250&quot;,&quot;RCPT TO error: &quot;); <br />//7、发送DATA，期待返回354 <br />$smtp[] = array(&quot;DATA&quot;.$lb,&quot;354&quot;,&quot;DATA error: &quot;); <br />//8.0、发送From <br />$smtp[] = array(&quot;From: &quot;.$from.$lb,&quot;&quot;,&quot;&quot;); <br />//8.2、发送To <br />$smtp[] = array(&quot;To: &quot;.$to.$lb,&quot;&quot;,&quot;&quot;); <br />//8.1、发送标题 <br />$smtp[] = array(&quot;Subject: &quot;.$subject.$lb,&quot;&quot;,&quot;&quot;); <br />//8.3、发送其他Header内容 <br />foreach($hdr as $h) &#123;$smtp[] = array($h.$lb,&quot;&quot;,&quot;&quot;);&#125; <br />//8.4、发送一个空行，结束Header发送 <br />$smtp[] = array($lb,&quot;&quot;,&quot;&quot;); <br />//8.5、发送信件主体 <br />if($bdy) &#123;foreach($bdy as $b) &#123;$smtp[] = array(base64_encode($b.$lb).$lb,&quot;&quot;,&quot;&quot;);&#125;&#125; <br />//9、发送“.”表示信件结束，期待返回250 <br />$smtp[] = array(&quot;.&quot;.$lb,&quot;250&quot;,&quot;DATA(end)error: &quot;); <br />//10、发送Quit，退出，期待返回221 <br />$smtp[] = array(&quot;QUIT&quot;.$lb,&quot;221&quot;,&quot;QUIT error: &quot;); <br /><br />//打开smtp服务器端口 <br />$fp = @fsockopen($smtp_host, 25); <br />if (!$fp) echo &quot;&lt;b&gt;Error:&lt;/b&gt; Cannot conect to &quot;.$smtp_host.&quot;&lt;br&gt;&quot;; <br />while($result = @fgets($fp, 1024))&#123;if(substr($result,3,1) == &quot; &quot;) &#123; break; &#125;&#125; <br /><br />$result_str=&quot;&quot;; <br />//发送smtp数组中的命令/数据 <br />foreach($smtp as $req)&#123; <br />//发送信息 <br />@fputs($fp, $req[0]); <br />//如果需要接收服务器返回信息，则 <br />if($req[1])&#123; <br />//接收信息 <br />while($result = @fgets($fp, 1024))&#123; <br />if(substr($result,3,1) == &quot; &quot;) &#123; break; &#125; <br />&#125;; <br />if (!strstr($req[1],substr($result,0,3)))&#123; <br />$result_str.=$req[2].$result.&quot;&lt;br&gt;&quot;; <br />&#125; <br />&#125; <br />&#125; <br />//关闭连接 <br />@fclose($fp); <br />return $result_str; <br />&#125; <br />?&gt;</font><br clear="all" />
]]>
</description>
</item><item>
<link>http://www.zhenghe.biz/read.php/.htm#blogcomment</link>
<title><![CDATA[[评论] 收集一个smtp发信的php函数，已经测试 ]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhenghe.biz/read.php/.htm#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>