<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" >

<channel>
	<title>Maker&#039;s blog &#187; imap</title>
	<atom:link href="http://blog.foolbird.net/t/imap/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.foolbird.net</link>
	<description>用多一点点的辛苦, 去交换多一点点的幸福.</description>
	<lastBuildDate>Mon, 16 Jan 2012 14:31:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>使用PHP收发邮件</title>
		<link>http://blog.foolbird.net/787.html</link>
		<comments>http://blog.foolbird.net/787.html#comments</comments>
		<pubDate>Tue, 09 Sep 2008 05:59:13 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[笔记]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[邮件]]></category>

		<guid isPermaLink="false">http://www.foolbird.net/?p=787</guid>
		<description><![CDATA[这两天都在测试邮件, 搞得头都大了, 现在技术问题都已经解决了, 记录一下. 发送邮件一直都是一个难题, 以前没用过mail函数, 因为多数的环境下都不支持, 曾经改写过Discuz的邮件类, 也用过像PHPMailer这样的邮件发送库来解决邮件发送的问题, 但实际上用的都是SMTP. 昨天bobhero在公司内网服务器上配置了sendmail, 简单配置了之后可以使用smtp, imap和pop3. 但按照网上的教程配置了之后php的mail()函数一直都无法发送邮件, 在搜索引擎上寻找很久没有结果, 最后bobhero重新编译了配置文件, 终于成功. 编译命令 make -C /etc/mail 收邮件要比发邮件复杂的多, 网上资源巨少, 好不容易有几篇英文的帖子和我情况类似也没有解决办法. 接受邮件使用php的imap库, 遇到的问题主要在imap_open()上 连接163使用 imap_open("{pop3.163.com:110/pop3}INBOX", $username, $password); 取得的7bit数据使用imap_qprint()解码. 连接gmail使用 imap_open("imap.gmail.com:993/imap/ssl", $username, $password); 最难弄的就是连接本地的imap服务器, Outlook是可以从服务器上收取邮件的, 但是php就是收不到并返回错误Certificate failure for 102.com: Self-signed certificate or untrusted authority: OU=IMAP server, CN=imap.example.com, E=postmaster@example.com, 使用telnet链接也没有问题, 从昨天下午研究到今天中午也没解决这个错误, 网上搜不到解决办法, 最后实在没办法了, 用IP [...]]]></description>
			<content:encoded><![CDATA[<p>这两天都在测试邮件, 搞得头都大了, 现在技术问题都已经解决了, 记录一下.</p>
<p>发送邮件一直都是一个难题, 以前没用过mail函数, 因为多数的环境下都不支持, 曾经改写过<a title="一款优秀的国产php论坛系统" href="http://www.discuz.com" target="_blank">Discuz</a>的邮件类, 也用过像<a title="phpmailer project" href="http://phpmailer.codeworxtech.com/" target="_blank">PHPMailer</a>这样的邮件发送库来解决邮件发送的问题, 但实际上用的都是SMTP. 昨天<a href="http://www.bobhero.net" target="_blank">bobhero</a>在公司内网服务器上配置了sendmail, 简单配置了之后可以使用smtp, imap和pop3. 但按照网上的教程配置了之后php的mail()函数一直都无法发送邮件, 在搜索引擎上寻找很久没有结果, 最后bobhero重新编译了配置文件, 终于成功.</p>
<p>编译命令</p>
<pre>make -C /etc/mail</pre>
<p>收邮件要比发邮件复杂的多, 网上资源巨少, 好不容易有几篇英文的帖子和我情况类似也没有解决办法.</p>
<p>接受邮件使用php的imap库, 遇到的问题主要在imap_open()上</p>
<p>连接163使用</p>
<pre>imap_open("{pop3.163.com:110/pop3}INBOX", $username, $password);</pre>
<p>取得的7bit数据使用imap_qprint()解码.</p>
<p>连接gmail使用</p>
<pre>imap_open("imap.gmail.com:993/imap/ssl", $username, $password);</pre>
<p>最难弄的就是连接本地的imap服务器, Outlook是可以从服务器上收取邮件的, 但是php就是收不到并返回错误<span style="color: #ff0000;">Certificate failure for 102.com: Self-signed certificate or untrusted authority: OU=IMAP server, CN=imap.example.com, E=postmaster@example.com</span>, 使用telnet链接也没有问题, 从昨天下午研究到今天中午也没解决这个错误, 网上搜不到解决办法, 最后实在没办法了, 用<a title="一款抓包工具" href="http://www.xdowns.com/soft/1/78/2006/soft_34204.html" target="_blank">IP Sniffer</a>截php.exe的数据包, 然后用telnet进行模拟, 发现php.exe在和imap服务器链接成功之后使用了TLS(一个什么传输安全协议), 刚想放弃就在<a title="imap_open function" href="http://cn2.php.net/manual/en/function.imap-open.php" target="_blank">php.net</a>上看到原来imap_open()还有一个参数是/notls, 我的天, 终于得救了.</p>
<pre>imap_open("{localhost:143/imap/notls}INBOX", $username, $password);</pre>
<p>研究期间发现telnet很好玩, 可以用telnet检查某项服务是否开启, 比如smtp, telnet 192.168.1.102 25, 如果服务是开启的就会建立一个连接, 可以用指令进行smtp 的相关操作, 而指令内容也就是smtp协议的相关内容, 其他协议pop, imap等等都可以这么玩.</p>
<p><strong>相关端口:</strong></p>
<p>smtp 协议 25端口</p>
<p>imap 协议 143端口</p>
<p>imap/ssl 993端口</p>
<p>imap/ssl/novalidate-cert 995端口</p>
<p>nntp协议 119端口</p>
<p><strong>相关资源:</strong></p>
<p>中国协议分析网 <a title="中国协议分析网" href="http://www.cnpaf.net/" target="_blank">http://www.cnpaf.net/</a></p>
<p>RFC文档 <a href="http://www.faqs.org/rfcs/" target="_blank">http://www.faqs.org/rfcs/</a></p>
<h3  class="related_post_title">Random Posts</h3><ul class="related_post"><li>Jan 25, 2007 -- <a href="http://blog.foolbird.net/474.html" title="White for Sablog-X 1.2 Archives (日志归档部分)">White for Sablog-X 1.2 Archives (日志归档部分)</a></li><li>Oct 20, 2011 -- <a href="http://blog.foolbird.net/1763.html" title="Magento学习资源">Magento学习资源</a></li><li>Sep 22, 2006 -- <a href="http://blog.foolbird.net/567.html" title="板报比赛，人生中的一大败笔">板报比赛，人生中的一大败笔</a></li><li>Oct 16, 2009 -- <a href="http://blog.foolbird.net/1490.html" title="谈谈近况">谈谈近况</a></li><li>Oct 30, 2011 -- <a href="http://blog.foolbird.net/1917.html" title="magento重写后台动作">magento重写后台动作</a></li><li>Sep 26, 2007 -- <a href="http://blog.foolbird.net/299.html" title="揭开网络诈骗的迷雾(1).">揭开网络诈骗的迷雾(1).</a></li><li>Nov 21, 2011 -- <a href="http://blog.foolbird.net/1975.html" title="巴松错">巴松错</a></li><li>Nov 11, 2011 -- <a href="http://blog.foolbird.net/2127.html" title="M-05">M-05</a></li><li>Jun 25, 2008 -- <a href="http://blog.foolbird.net/765.html" title="做最后一天大学生">做最后一天大学生</a></li><li>Jan 25, 2007 -- <a href="http://blog.foolbird.net/478.html" title="敦化雪景">敦化雪景</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.foolbird.net/787.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

