<?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/"
	>

<channel>
	<title>小惡魔 - 電腦技術 - 生活日記 - 美食介紹 - AppleBOY &#187; PEAR</title>
	<atom:link href="http://blog.wu-boy.com/tag/pear/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.wu-boy.com</link>
	<description>介紹一堆美食日記，生活日記，電腦筆記</description>
	<lastBuildDate>Tue, 27 Jul 2010 14:04:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[Pear] 利用 Validate 套件驗證 E-mail 多重表單認證</title>
		<link>http://blog.wu-boy.com/2009/03/15/990/</link>
		<comments>http://blog.wu-boy.com/2009/03/15/990/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 08:07:14 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PEAR]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=990</guid>
		<description><![CDATA[最近都在玩 open source 的程式，方便加速自己開發 PHP 的專案，在申請帳號密碼部份就可以利用 Validate 套件來驗證，以及 email 填寫正確性，可以檢查 MX 或者是 A record 紀錄，還蠻方便的，也可以檢查 multiple 欄位，設計的相當不錯，也有金融相關套件可以驗證 CreditCard，金融套件名稱是 Validate_Finance 裡面的 Validate_Finance_CreditCard 部份，線上也有很多相關說明，可以參考 Validate 線上手冊，目前已經到 0.8.2 (beta)，如果使用 Release 版本，請選用 0.8.1，軟體可以在此下載，0.8.2 是在 2009-01-31 Release 出來的，還不錯用，最主要的功能如下
<span class="readmore"><a href="http://blog.wu-boy.com/2009/03/15/990/" title="[Pear] 利用 Validate 套件驗證 E-mail 多重表單認證" target="_blank">...詳全文（共3695字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>最近都在玩 <a href="http://en.wikipedia.org/wiki/Open_source">open source</a> 的程式，方便加速自己開發 PHP 的專案，在申請帳號密碼部份就可以利用 <a href="http://pear.php.net/package/Validate">Validate</a> 套件來驗證，以及 email 填寫正確性，可以檢查 MX 或者是 A record 紀錄，還蠻方便的，也可以檢查 <a href="http://pear.php.net/package/Validate/docs/0.8.2/Validate/Validate.html#methodmultiple">multiple</a> 欄位，設計的相當不錯，也有金融相關套件可以驗證 <a href="http://en.wikipedia.org/wiki/Credit_card">CreditCard</a>，金融套件名稱是 <a href="http://pear.php.net/package/Validate_Finance">Validate_Finance</a> 裡面的 <a href="http://pear.php.net/package/Validate_Finance_CreditCard">Validate_Finance_CreditCard</a> 部份，線上也有很多相關說明，可以參考 <a href="http://pear.php.net/package/Validate/docs/0.8.2/">Validate 線上手冊</a>，目前已經到 0.8.2 (beta)，如果使用 Release 版本，請選用 0.8.1，軟體可以在此<a href="http://pear.php.net/package/Validate/download/">下載</a>，0.8.2 是在 2009-01-31 Release 出來的，還不錯用，最主要的功能如下</p>
<blockquote><p>Package to validate various datas. It includes :<br />
- numbers (min/max, decimal or not)<br />
- email (syntax, domain check, <a href="http://www.w3.org/Protocols/rfc822/">rfc822</a>)<br />
- string (predifined type alpha upper and/or lowercase, numeric,&#8230;)<br />
- date (min, max, rfc822 compliant)<br />
- uri (<a href="http://www.w3.org/2002/11/dbooth-names/rfc2396-numbered_clean.htm">RFC2396</a>)<br />
- possibility valid multiple data with a single method call (::multiple)</p></blockquote>
<ol>
<li>驗證各種不同的日期函式</li>
<li>驗證數字(最小/最大,是否是10進位)</li>
<li>email 驗證(正規語法驗證，check domain name 是否存在，<a href="http://www.w3.org/Protocols/rfc822/">rfc822</a> 驗證)</li>
<li>字串驗證(正規語法驗證，是否包含數字英文字母，可輸入最長或最短)</li>
<li>url 驗證(遵從 <a href="http://www.w3.org/2002/11/dbooth-names/rfc2396-numbered_clean.htm">RFC2396</a> 規定)</li>
<li>多重欄位(multiple data)驗證(可以同時驗證上述功能)</li>
</ol>
<p><span id="more-990"></span><br />
來介紹 <a href="http://pear.php.net/package/Validate">Validate</a> 套件用法：<br />
1. <a href="http://pear.php.net/package/Validate/docs/0.8.2/Validate/Validate.html#methoddate">Validate::date</a> 這部份我比較不推薦用這裡的方法，可以用 jQuery 的套件：<a href="http://blog.wu-boy.com/2008/04/30/194/">[jQuery筆記] 好用的日期函式 datepicker</a>，那底下是這個函式用法：必須多安裝 <a href="http://pear.php.net/package/Date">Pear Date</a> 套件</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co4">/**<br />
* 驗證此套件必須在加裝 Date_Calc class<br />
*<br />
* @param string $date &nbsp;需要驗證的值<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'format' 可以自行制定 (%d-%m-%Y)<br />
*<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'min' &nbsp; &nbsp;array($day, $month, $year)<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'max' &nbsp; array($day, $month, $year)<br />
* 回傳值 true or false<br />
*/</span><br />
<span class="re0">$values</span> <span class="sy0">=</span> <span class="st0">&quot;2009-01-10&quot;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$opts</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'format'</span><span class="sy0">=&gt;</span> <span class="st0">&quot;%Y-<span class="es6">%d</span>-%m&quot;</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'min'</span> &nbsp;<span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'02'</span><span class="sy0">,</span><span class="st_h">'10'</span><span class="sy0">,</span><span class="st_h">'2009'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'max'</span> &nbsp;<span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'05'</span><span class="sy0">,</span><span class="st_h">'10'</span><span class="sy0">,</span><span class="st_h">'2009'</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$result</span> <span class="sy0">=</span> Validate<span class="sy0">::</span><a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="re0">$values</span><span class="sy0">,</span> <span class="re0">$opts</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$result</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">else</span><br />
<span class="br0">&#123;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;error&quot;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>2. <a href="http://pear.php.net/package/Validate/docs/0.8.2/Validate/Validate.html#methodemail">Validate::email</a></p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co4">/**<br />
&nbsp;* <br />
&nbsp;* @param string $email &nbsp;您要驗證的 email<br />
&nbsp;* @param mixed<br />
&nbsp;* &nbsp; &nbsp;check_domain 檢查 domain 是否有 A 或者 MX Record<br />
&nbsp;* &nbsp; &nbsp;use_rfc822 檢查 domain 是否符合 rfc822 規範 <br />
&nbsp;* 回傳值 true or false<br />
&nbsp;* &nbsp;<br />
&nbsp;*/</span><br />
<span class="re0">$values</span> <span class="sy0">=</span> <span class="st0">&quot;appleboy@XXXXX&quot;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$options</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'check_domain'</span> <span class="sy0">=&gt;</span> <span class="st_h">'true'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'fullTLDValidation'</span> <span class="sy0">=&gt;</span> <span class="st_h">'true'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'use_rfc822'</span> <span class="sy0">=&gt;</span> <span class="st_h">'true'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'VALIDATE_GTLD_EMAILS'</span> <span class="sy0">=&gt;</span> <span class="st_h">'false'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'VALIDATE_CCTLD_EMAILS'</span> <span class="sy0">=&gt;</span> <span class="st_h">'false'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'VALIDATE_ITLD_EMAILS'</span> <span class="sy0">=&gt;</span> <span class="st_h">'false'</span><span class="sy0">,</span><br />
<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$result</span> <span class="sy0">=</span> Validate<span class="sy0">::</span><span class="me2">email</span><span class="br0">&#40;</span><span class="re0">$values</span><span class="sy0">,</span> <span class="re0">$options</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$result</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">else</span><br />
<span class="br0">&#123;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;error<br />
&quot;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>3. <a href="http://pear.php.net/package/Validate/docs/0.8.2/Validate/Validate.html#methodnumber">Validate::number</a>：</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co4">/**<br />
&nbsp;* <br />
&nbsp;* @param string $number &nbsp;您要驗證的數字<br />
&nbsp;* param array &nbsp;$options array 選單<br />
&nbsp;* &nbsp; &nbsp;decimal 可否在數字中間出現非數字符號如：., 代表可以使用 .,<br />
&nbsp;* &nbsp; &nbsp;dec_prec 有多少 decimal 可以出現在數字中<br />
&nbsp;* &nbsp; &nbsp;min &nbsp; &nbsp; &nbsp;最小值<br />
&nbsp;* &nbsp; &nbsp;max &nbsp; &nbsp; &nbsp;最大值 <br />
&nbsp;* 回傳值 true or false<br />
&nbsp;* &nbsp;<br />
&nbsp;*/</span><br />
<br />
<span class="re0">$values</span> <span class="sy0">=</span> <span class="st0">&quot;12300,45&quot;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$options</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'decimal'</span> <span class="sy0">=&gt;</span> <span class="st_h">','</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'dec_prec'</span> <span class="sy0">=&gt;</span> <span class="st_h">'2'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'min'</span> <span class="sy0">=&gt;</span> <span class="st_h">'1000'</span><span class="sy0">,</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$result</span> <span class="sy0">=</span> Validate<span class="sy0">::</span><span class="me2">number</span><span class="br0">&#40;</span><span class="re0">$values</span><span class="sy0">,</span> <span class="re0">$options</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$result</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">else</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;error&lt;br /&gt;&quot;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>4. <a href="http://pear.php.net/package/Validate/docs/0.8.2/Validate/Validate.html#methodstring">Validate::String</a></p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co4">/**<br />
&nbsp;* <br />
&nbsp;* @param string $string &nbsp;您要驗證的字串<br />
&nbsp;* param array &nbsp;$options array 選單<br />
&nbsp;* &nbsp; &nbsp;'format' 字串的格式<br />
&nbsp;* &nbsp; &nbsp;Ex:VALIDATE_NUM(數字 0-9) . VALIDATE_ALPHA_LOWER(a-z) <br />
&nbsp;* &nbsp; &nbsp;VALIDATE_ALPHA_UPPER (A-Z) VALIDATE_ALPHA(a-zA-Z) <br />
&nbsp;* &nbsp; &nbsp;dec_prec 有多少 decimal 可以出現在數字中<br />
&nbsp;* &nbsp; &nbsp;'min_length' 字串最小長度<br />
&nbsp;* &nbsp; &nbsp;'max_length' 字串最大長度<br />
&nbsp;* 回傳值 true or false<br />
&nbsp;* &nbsp;<br />
&nbsp;*/</span><br />
<span class="re0">$values</span> <span class="sy0">=</span> <span class="st0">&quot;appleboy&quot;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$options</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'format'</span> <span class="sy0">=&gt;</span> VALIDATE_NUM<span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'min_length'</span> <span class="sy0">=&gt;</span> <span class="st_h">'2'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'max_length'</span> <span class="sy0">=&gt;</span> <span class="st_h">'1000'</span><span class="sy0">,</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$result</span> <span class="sy0">=</span> Validate<span class="sy0">::</span><span class="me2">number</span><span class="br0">&#40;</span><span class="re0">$values</span><span class="sy0">,</span> <span class="re0">$options</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$result</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw1">else</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;error&lt;br /&gt;&quot;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>5. <a href="http://pear.php.net/package/Validate/docs/0.8.2/Validate/Validate.html#methoduri">Validate::Uri</a></p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co4">/**<br />
&nbsp;* Validate an URI (RFC2396)<br />
&nbsp;* EX: <br />
&nbsp;* $options = array('allowed_schemes' =&gt; array('http', 'https', 'ftp'))<br />
&nbsp;* var_dump(Validate::uri('http://www.example.org', $options)); &nbsp;<br />
&nbsp;* 注意事項：<br />
&nbsp;* 1. 在 RFC2396 裡面定義了&quot;-&quot; 這個符號可以使用在 URI 裡面<br />
&nbsp;* &nbsp; &nbsp;e.g. http://example.co-m 這是可以驗證通過的 <br />
&nbsp;* &nbsp; &nbsp;但是在any known TLD裡面是不被准許的<br />
&nbsp;* 2. &nbsp; <br />
&nbsp;* @param string $url &nbsp; &nbsp; 您要驗證的網址列<br />
&nbsp;* @param array &nbsp;$options Options used by the validation method.<br />
&nbsp;* &nbsp; &nbsp;'domain_check' 檢查 domain 是否存在 DNS 裡<br />
&nbsp;* &nbsp; &nbsp;'allowed_schemes' 陣列 for list protocols ex: https, http<br />
&nbsp;* &nbsp; &nbsp;'strict' &nbsp;預設值： ';/?:@$,' 空值: accept all rfc2396 foreseen chars &nbsp; &nbsp; <br />
&nbsp;* 回傳值 true or false<br />
&nbsp;* &nbsp;<br />
&nbsp;*/</span><br />
<span class="re0">$options</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'check_domain'</span><span class="sy0">=&gt;</span>true<span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'allowed_schemes'</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'http'</span><span class="sy0">,</span><span class="st_h">'https'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'strict'</span> <span class="sy0">=&gt;</span> <span class="st_h">';/?:@$,'</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
<a href="http://www.php.net/var_dump"><span class="kw3">var_dump</span></a><span class="br0">&#40;</span>Validate<span class="sy0">::</span><span class="me2">uri</span><span class="br0">&#40;</span><span class="st_h">'http://blog.wu-boy.com/'</span><span class="sy0">,</span> <span class="re0">$options</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<p>6. <a href="http://pear.php.net/package/Validate/docs/0.8.2/Validate/Validate.html#methodmultiple">Validate::multiple</a> 結合上述的語法，整合成一個函式</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$values</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'amount'</span><span class="sy0">=&gt;</span> <span class="st_h">'13234,344343'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'name'</span> &nbsp;<span class="sy0">=&gt;</span> <span class="st_h">'foo@example.com'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'mail'</span> &nbsp;<span class="sy0">=&gt;</span> <span class="st_h">'foo@example.com'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'mystring'</span> <span class="sy0">=&gt;</span> <span class="st_h">'ABCDEabcde'</span><br />
<br />
&nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="re0">$opts</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'amount'</span><span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'type'</span><span class="sy0">=&gt;</span><span class="st_h">'number'</span><span class="sy0">,</span><span class="st_h">'decimal'</span><span class="sy0">=&gt;</span><span class="st_h">',.'</span><span class="sy0">,</span><span class="st_h">'dec_prec'</span><span class="sy0">=&gt;</span>null<span class="sy0">,</span><span class="st_h">'min'</span><span class="sy0">=&gt;</span><span class="nu0">1</span><span class="sy0">,</span><span class="st_h">'max'</span><span class="sy0">=&gt;</span><span class="nu0">32000</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'name'</span> &nbsp;<span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'type'</span><span class="sy0">=&gt;</span><span class="st_h">'email'</span><span class="sy0">,</span><span class="st_h">'check_domain'</span><span class="sy0">=&gt;</span>false<span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'mail'</span> &nbsp;<span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'type'</span><span class="sy0">=&gt;</span><span class="st_h">'email'</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; <span class="st_h">'mystring'</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'type'</span><span class="sy0">=&gt;</span><span class="st_h">'string'</span><span class="sy0">,</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">'format'</span><span class="sy0">=&gt;</span>VALIDATE_ALPHA<span class="sy0">,</span> <span class="st_h">'min_length'</span><span class="sy0">=&gt;</span><span class="nu0">3</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$result</span> <span class="sy0">=</span> Validate<span class="sy0">::</span><span class="me2">multiple</span><span class="br0">&#40;</span><span class="re0">$values</span><span class="sy0">,</span> <span class="re0">$opts</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2010/05/02/2145/" title="[jQuery] 解決 IE6 PNG 透明背景 (Supersleight jQuery Plugin for Transparent PNGs in IE6)">[jQuery] 解決 IE6 PNG 透明背景 (Supersleight jQuery Plugin for Transparent PNGs in IE6) (2)</a></li><li><a href="http://blog.wu-boy.com/2010/04/13/2130/" title="[jQuery] AjaxFileUpload : Multiple File Upload plugin">[jQuery] AjaxFileUpload : Multiple File Upload plugin (5)</a></li><li><a href="http://blog.wu-boy.com/2010/01/21/1965/" title="遲來的 jQuery 1.4 Released">遲來的 jQuery 1.4 Released (0)</a></li><li><a href="http://blog.wu-boy.com/2009/10/21/1740/" title="[jQuery] ThickBox 3.1 無限期停止支援維護">[jQuery] ThickBox 3.1 無限期停止支援維護 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/07/28/1441/" title="[網站] 好站連結 (四)">[網站] 好站連結 (四) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/06/16/1454/" title="[jQuery] 驗證表單實作筆記 API/1.3/Selectors">[jQuery] 驗證表單實作筆記 API/1.3/Selectors (0)</a></li><li><a href="http://blog.wu-boy.com/2009/06/11/1386/" title="[網站] 好站連結 (三)">[網站] 好站連結 (三) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/05/28/1307/" title="[網站] 好站連結 (二)">[網站] 好站連結 (二) (3)</a></li><li><a href="http://blog.wu-boy.com/2009/05/12/1334/" title="[jQuery] 日曆時間外掛 timepicker CSS/Offset 問題 | Plugins">[jQuery] 日曆時間外掛 timepicker CSS/Offset 問題 | Plugins (7)</a></li><li><a href="http://blog.wu-boy.com/2009/05/07/1312/" title="利用 IE7 CSS 2.0 tbody 解決 IE6 hover 問題">利用 IE7 CSS 2.0 tbody 解決 IE6 hover 問題 (2)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2009/03/15/990/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Windows] Appserv 安裝 pear 套件</title>
		<link>http://blog.wu-boy.com/2009/03/14/970/</link>
		<comments>http://blog.wu-boy.com/2009/03/14/970/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 10:49:33 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[www]]></category>
		<category><![CDATA[PEAR]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=970</guid>
		<description><![CDATA[最近要在 Windows 上面安裝 Apache + MySQL + PHP，我選擇利用懶人包安裝方法：Appserv，目前版本為 AppServ 2.5.10 跟 AppServ 2.6.0，如果您要寫 PHP5 的話，就選擇安裝 AppServ 2.5.10，目前支援到 PHP 5.2.6，不過我上次已經看到 PHP 5.2.9 Released 了，如果想要支援 PHP6，那就選擇 AppServ 2.6.0 這個版本，不過我建議新手可以安裝 AppServ 2.5.10，這個版本比較穩定，安裝好之後，也有支援 phpMyAdmin，底下是 2.5.10 支援的套件：
<span class="readmore"><a href="http://blog.wu-boy.com/2009/03/14/970/" title="[Windows] Appserv 安裝 pear 套件" target="_blank">...詳全文（共725字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>最近要在 Windows 上面安裝 <a href="http://www.apache.org/">Apache</a> + <a href="http://www.mysql.com/">MySQL</a> + <a href="http://www.php.net">PHP</a>，我選擇利用懶人包安裝方法：<a href="http://www.appservnetwork.com/">Appserv</a>，目前版本為 AppServ 2.5.10 跟 AppServ 2.6.0，如果您要寫 PHP5 的話，就選擇安裝 AppServ 2.5.10，目前支援到 PHP 5.2.6，不過我上次已經看到 <a href="http://blog.wu-boy.com/2009/03/01/842/">PHP 5.2.9 Released</a> 了，如果想要支援 PHP6，那就選擇 AppServ 2.6.0 這個版本，不過我建議新手可以安裝 AppServ 2.5.10，這個版本比較穩定，安裝好之後，也有支援 phpMyAdmin，底下是 2.5.10 支援的套件：</p>
<blockquote><p>    *  Apache 2.2.8<br />
    * PHP 5.2.6<br />
    * MySQL 5.0.51b<br />
    * phpMyAdmin-2.10.3
</p></blockquote>
<p>今天要安裝 pear 的套件在 Windows 上面，不過不用緊張，因為 Appserv 已經把 <a href="http://pear.php.net">Pear</a> 的模組包進來裡面了，只要執行 .bat 檔，按照視窗，就可以完成安裝了，自己平常有用 Pear 的 <a href="http://blog.wu-boy.com/2009/01/03/677/">HTTP_Upload 多重檔案上傳 Multiple files upload</a>，跟 <a href="http://blog.wu-boy.com/2007/12/18/129/">PEAR &#8211; PHP Mail and Mail_Mime 模組</a>，底下就是 Windows 的安裝方法：<br />
<span id="more-970"></span><br />
1. 首先執行 C:\AppServ\php5\go-pear.bat<br />
<a href="http://www.flickr.com/photos/appleboy/3353580888/" title="Windows_Pear_02 (by appleboy46)"><img src="http://farm2.static.flickr.com/1237/3353580888_9d2a4afb00.jpg" title="Windows_Pear_02 (by appleboy46)" alt="Windows_Pear_02 (by appleboy46)" width="500" height="150" /></a><br />
此程式會去呼叫 PEAR\go-pear.phar 這隻程式下去執行</p>
<p>2. 設定環境變數：<br />
<a href="http://www.flickr.com/photos/appleboy/3353580872/" title="Windows_Pear_01 (by appleboy46)"><img src="http://farm2.static.flickr.com/1174/3353580872_ab4ecd390c.jpg" title="Windows_Pear_01 (by appleboy46)" alt="Windows_Pear_01 (by appleboy46)" width="500" height="323" /></a><br />
這些都是 Appserv 預設好的，所以基本上不用改喔</p>
<p>3. 安裝 Pear 套件<br />
<a href="http://www.flickr.com/photos/appleboy/3353580872/" title="Windows_Pear_01 (by appleboy46)"><img src="http://farm2.static.flickr.com/1174/3353580872_ab4ecd390c.jpg" title="Windows_Pear_01 (by appleboy46)" alt="Windows_Pear_01 (by appleboy46)" width="500" height="323" /></a></p>
<p>4. 選取 php.ini 位置<br />
<a href="http://www.flickr.com/photos/appleboy/3352755577/" title="Windows_Pear_04 (by appleboy46)"><img src="http://farm2.static.flickr.com/1194/3352755577_862058ff3b.jpg" title="Windows_Pear_04 (by appleboy46)" alt="Windows_Pear_04 (by appleboy46)" width="500" height="299" /></a><br />
預設是在 C:\WINDOWS\php.ini</p>
<p>5.安裝完成，請雙點登錄檔 C:\AppServ\php5\PEAR_ENV.reg<br />
<a href="http://www.flickr.com/photos/appleboy/3352755603/" title="Windows_Pear_05 (by appleboy46)"><img src="http://farm2.static.flickr.com/1196/3352755603_cec0ecda96.jpg" title="Windows_Pear_05 (by appleboy46)" alt="Windows_Pear_05 (by appleboy46)" width="500" height="297" /></a></p>
<p>這樣就安裝好了喔，可以使用其他好用的模組，那其他安裝方式可以參考<a href="http://pear.php.net/manual/en/installation.php">這裡</a></p>
<p>參考網站：<br />
<a href="http://kevin-wei.blogspot.com/2007/05/pearwindows.html">PEAR在windows下安裝體驗 </a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2008/10/01/524/" title="[PHP]解決 PEAR::Mail_Mime 標題 UTF-8 亂碼問題(不能顯示)">[PHP]解決 PEAR::Mail_Mime 標題 UTF-8 亂碼問題(不能顯示) (4)</a></li><li><a href="http://blog.wu-boy.com/2007/12/18/129/" title="[PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime">[PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime (4)</a></li><li><a href="http://blog.wu-boy.com/2010/06/30/2254/" title="[phpBB3] BBCode [url] Tag 支援中文網址">[phpBB3] BBCode [url] Tag 支援中文網址 (1)</a></li><li><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9">[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/06/13/2213/" title="[phpBB3 外掛] 根據使用者文章數目限制簽名檔顯示">[phpBB3 外掛] 根據使用者文章數目限制簽名檔顯示 (1)</a></li><li><a href="http://blog.wu-boy.com/2010/06/10/2203/" title="[教學] phpBB3 使用者簽名檔 url 連結加上 rel=&#8221;nofollow&#8221;  ">[教學] phpBB3 使用者簽名檔 url 連結加上 rel=&#8221;nofollow&#8221;   (1)</a></li><li><a href="http://blog.wu-boy.com/2010/06/07/2182/" title="[PHP] 好用 Debug PHP 工具 FirePHP for FireFox on CodeIgniter">[PHP] 好用 Debug PHP 工具 FirePHP for FireFox on CodeIgniter (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/21/2054/" title="[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇)">[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇) (8)</a></li><li><a href="http://blog.wu-boy.com/2009/12/30/1920/" title="[PHP Framework] How to implement Plurk API in CodeIgniter">[PHP Framework] How to implement Plurk API in CodeIgniter (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/24/1913/" title="[PHP] Release 噗浪 php-plurk-api 1.2 Beta.">[PHP] Release 噗浪 php-plurk-api 1.2 Beta. (0)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2009/03/14/970/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[PHP]解決 PEAR::Mail_Mime 標題 UTF-8 亂碼問題(不能顯示)</title>
		<link>http://blog.wu-boy.com/2008/10/01/524/</link>
		<comments>http://blog.wu-boy.com/2008/10/01/524/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 02:17:30 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[www]]></category>
		<category><![CDATA[PEAR]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/?p=524</guid>
		<description><![CDATA[話說大家在寫 PHP 的時候，一定會很常用到 mail 這個函式，畢竟一個網站一定會有很多需要用到寄信的地方，我先給大家推薦一下 PEAR::Mail_Mime 跟 PEAR::Mail 這兩個 Pear 的套件，用起來相當不錯，支援 html 跟 UTF-8 或者是 Big5 編碼，我之前寫過一篇 [PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime，裡面寫的還蠻詳細的，不過上次有一個問題還沒解決，就是如果用 UTF-8 編碼的標題，會顯示不出來，Gmail 收到的話就會是 no subject，然後昨天用了一個非常笨的解決方法，改成把標題使用 Big5 就可以了，解決方法如下：
<span class="readmore"><a href="http://blog.wu-boy.com/2008/10/01/524/" title="[PHP]解決 PEAR::Mail_Mime 標題 UTF-8 亂碼問題(不能顯示)" target="_blank">...詳全文（共1748字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>話說大家在寫 PHP 的時候，一定會很常用到 mail 這個函式，畢竟一個網站一定會有很多需要用到寄信的地方，我先給大家推薦一下 <a href="http://pear.php.net/package/Mail_Mime">PEAR::Mail_Mime</a> 跟 <a href="http://pear.php.net/package/Mail">PEAR::Mail</a> 這兩個 Pear 的套件，用起來相當不錯，支援 html 跟 UTF-8 或者是 Big5 編碼，我之前寫過一篇 <a title="Permanent Link to [PHP] 好用的 PEAR - PHP Mail and Mail_Mime" rel="bookmark" href="http://blog.wu-boy.com/2007/12/18/129/">[PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime</a>，裡面寫的還蠻詳細的，不過上次有一個問題還沒解決，就是如果用 UTF-8 編碼的標題，會顯示不出來，<a href="http://mail.google.com">Gmail</a> 收到的話就會是 no subject，然後昨天用了一個非常笨的解決方法，改成把標題使用 Big5 就可以了，解決方法如下：</p>
<p><strong>Update：感謝 darkhero 提供解決方法：</strong><br />
如果要用 UTF-8 的標題：</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$param</span><span class="br0">&#91;</span><span class="st_h">'head_charset'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'utf-8'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$hdrs</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'From'</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="st_h">'appleboy.tw@gmail.com'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Subject'</span> <span class="sy0">=&gt;</span> <span class="st_h">'=?utf8?B?'</span> <span class="sy0">.</span> <a href="http://www.php.net/base64_encode"><span class="kw3">base64_encode</span></a><span class="br0">&#40;</span><span class="re0">$subj</span><span class="br0">&#41;</span> <span class="sy0">.</span> <span class="st_h">'?='</span><span class="sy0">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Content-type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'text/html; charset=utf-8'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<p>先讓主機支援 PEAR：</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:580px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#</span><br />
<span class="co0"># &nbsp;FreeBSD ports 安裝</span><br />
<span class="kw3">cd</span> <span class="sy0">/</span>usr<span class="sy0">/</span>ports<span class="sy0">/</span>devel<span class="sy0">/</span>pear<br />
<span class="kw2">make</span> <span class="kw2">install</span> clean</div></div>
<p><span id="more-524"></span><br />
然後當然是自己寫一個 send mail 函式來使用，這樣以後就呼叫這個 function 就可以了</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">function</span> send_mail<span class="br0">&#40;</span><span class="re0">$to</span><span class="sy0">,</span> <span class="re0">$subj</span><span class="sy0">,</span> <span class="re0">$body</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; <a href="http://www.php.net/global"><span class="kw3">global</span></a> <span class="re0">$db</span><span class="sy0">,</span><span class="re0">$userdata</span><span class="sy0">,</span> <span class="re0">$board_config</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">include</span><span class="br0">&#40;</span>Document_root <span class="sy0">.</span> <span class="st_h">'/includes/Mail.php'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">include</span><span class="br0">&#40;</span>Document_root <span class="sy0">.</span> <span class="st_h">'/includes/Mail/mime.php'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$html</span> <span class="sy0">=</span> <span class="st_h">'&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &nbsp; &nbsp; &nbsp;&quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;html&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;title&gt;'</span><span class="sy0">.</span><span class="re0">$subj</span><span class="sy0">.</span><span class="st_h">'&lt;/title&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;body&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '</span><span class="sy0">.</span><span class="re0">$body</span><span class="sy0">.</span><span class="st_h">'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/body&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/html&gt;'</span><span class="sy0">;</span><br />
&nbsp; <span class="co1">//$file = '/home/appleboy/adwii/AB2.jpg';</span><br />
&nbsp; <span class="re0">$crlf</span> <span class="sy0">=</span> <span class="st0">&quot;<span class="es1">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; <span class="co1">//$param['text_charset'] = 'utf-8';</span><br />
&nbsp; <span class="re0">$param</span><span class="br0">&#91;</span><span class="st_h">'html_charset'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'utf-8'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$param</span><span class="br0">&#91;</span><span class="st_h">'head_charset'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'Big5'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$hdrs</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'From'</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="st_h">'appleboy.tw@gmail.com'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Subject'</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/iconv"><span class="kw3">iconv</span></a><span class="br0">&#40;</span><span class="st0">&quot;UTF-8&quot;</span><span class="sy0">,</span><span class="st0">&quot;BIG5&quot;</span><span class="sy0">,</span><span class="re0">$subj</span><span class="br0">&#41;</span><span class="sy0">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Content-type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'text/html; charset=utf-8'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mime</span> <span class="sy0">=</span> <span class="kw2">new</span> Mail_mime<span class="br0">&#40;</span><span class="re0">$crlf</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">setTXTBody</span><span class="br0">&#40;</span><span class="re0">$text</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">setHTMLBody</span><span class="br0">&#40;</span><span class="re0">$html</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="co1">//$mime-&gt;addAttachment($file, 'text/plain', 'AB2.jpg');</span><br />
&nbsp; <span class="re0">$body</span> <span class="sy0">=</span> <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">get</span><span class="br0">&#40;</span><span class="re0">$param</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$hdrs</span> <span class="sy0">=</span> <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">headers</span><span class="br0">&#40;</span><span class="re0">$hdrs</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="co1">//echo $body;</span><br />
&nbsp; <span class="re0">$mail</span> <span class="sy0">=&amp;</span> <a href="http://www.php.net/mail"><span class="kw3">Mail</span></a><span class="sy0">::</span><span class="me2">factory</span><span class="br0">&#40;</span><span class="st_h">'mail'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mail</span><span class="sy0">-&gt;</span><span class="me1">send</span><span class="br0">&#40;</span><span class="re0">$board_config</span><span class="br0">&#91;</span><span class="st_h">'board_email'</span><span class="br0">&#93;</span> <span class="sy0">.</span> <span class="st_h">', '</span> <span class="sy0">.</span> <span class="re0">$to</span><span class="sy0">,</span> <span class="re0">$hdrs</span><span class="sy0">,</span> <span class="re0">$body</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>這是我之前寫的函式，裡面標題本來不能用的，我系統跟程式都是使用 UTF-8，標題也是都利用 UTF-8 設定，可是標題顯示步來，那就改用 Big5 吧，所以是設定如下</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$param</span><span class="br0">&#91;</span><span class="st_h">'head_charset'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'Big5'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$hdrs</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'From'</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="st_h">'appleboy.tw@gmail.com'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Subject'</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/iconv"><span class="kw3">iconv</span></a><span class="br0">&#40;</span><span class="st0">&quot;UTF-8&quot;</span><span class="sy0">,</span><span class="st0">&quot;BIG5&quot;</span><span class="sy0">,</span><span class="re0">$subj</span><span class="br0">&#41;</span><span class="sy0">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Content-type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'text/html; charset=utf-8'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<p>先把 $param['head_charset'] = &#8216;UTF-8&#8242;; 裡面設定改成 Big5 這樣就可以了，然後在 Subject 轉成 Big5 利用 <a href="http://tw.php.net/iconv">PHP iconv</a> 函式就可以了，然後在隨便測試一下就可以 work 了</p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2007/12/18/129/" title="[PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime">[PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime (4)</a></li><li><a href="http://blog.wu-boy.com/2009/09/08/1646/" title="[RHEL]Installing PHP 5.1.x 5.2.x or 5.3.x on RedHat ES5, CentOS 5">[RHEL]Installing PHP 5.1.x 5.2.x or 5.3.x on RedHat ES5, CentOS 5 (0)</a></li><li><a href="http://blog.wu-boy.com/2009/07/28/1441/" title="[網站] 好站連結 (四)">[網站] 好站連結 (四) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/06/11/1386/" title="[網站] 好站連結 (三)">[網站] 好站連結 (三) (0)</a></li><li><a href="http://blog.wu-boy.com/2009/03/14/970/" title="[Windows] Appserv 安裝 pear 套件">[Windows] Appserv 安裝 pear 套件 (3)</a></li><li><a href="http://blog.wu-boy.com/2009/02/23/829/" title="[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28">[FreeBSD] 利用 portmaster 升級 PHP 5.26 -> 5.28 (2)</a></li><li><a href="http://blog.wu-boy.com/2008/10/28/572/" title="[PHP] 好用的留言板 驗證碼 功能">[PHP] 好用的留言板 驗證碼 功能 (9)</a></li><li><a href="http://blog.wu-boy.com/2008/10/04/532/" title="[AJAX] google map 的應用～">[AJAX] google map 的應用～ (1)</a></li><li><a href="http://blog.wu-boy.com/2008/09/26/431/" title="[PHP]如何把 Yahoo! BBAuth 加入網站入口認證">[PHP]如何把 Yahoo! BBAuth 加入網站入口認證 (2)</a></li><li><a href="http://blog.wu-boy.com/2008/09/13/388/" title="[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi">[FreeBSD]安裝 apache2 (worker) + PHP5.2.6 + mod_fastcgi + php5-fcgi (3)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2008/10/01/524/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime</title>
		<link>http://blog.wu-boy.com/2007/12/18/129/</link>
		<comments>http://blog.wu-boy.com/2007/12/18/129/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 12:24:57 +0000</pubDate>
		<dc:creator>appleboy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[www]]></category>
		<category><![CDATA[PEAR]]></category>

		<guid isPermaLink="false">http://blog.wu-boy.com/2007/12/18/129/</guid>
		<description><![CDATA[今天在寫期末的 Project，我的專題是寫無線 802.1X 認證，搭配 FreeBADIUS Server，然後我在搭配網頁整合認證機制，然後我在做使用者帳號申請部份，需要靠 Email 認證，但是我去看官網，介紹好像也沒什麼，在寄信的時候常常會遇到亂碼，不然就是寄信 html 部份會有問題，或者是不能附加檔案之類的，然後網路上找不到一個好用的 class ，所以就用了 PEAR::Mail_Mime 跟 PEAR::Mail，這兩個套件還不錯用，如果想寄單純的信件，就用 PEAR::Mail 這個就可以了，如果要搭配 html 網頁，就要搭上 PEAR::Mail_Mime
<span class="readmore"><a href="http://blog.wu-boy.com/2007/12/18/129/" title="[PHP] 好用的 PEAR &#8211; PHP Mail and Mail_Mime" target="_blank">...詳全文（共2547字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>今天在寫期末的 Project，我的專題是寫無線 802.1X 認證，搭配 FreeBADIUS Server，然後我在搭配網頁整合認證機制，然後我在做使用者帳號申請部份，需要靠 Email 認證，但是我去看官網，介紹好像也沒什麼，在寄信的時候常常會遇到亂碼，不然就是寄信 html 部份會有問題，或者是不能附加檔案之類的，然後網路上找不到一個好用的 class ，所以就用了 <a href="http://pear.php.net/package/Mail_Mime">PEAR::Mail_Mime</a> 跟 <a href="http://pear.php.net/package/Mail">PEAR::Mail</a>，這兩個套件還不錯用，如果想寄單純的信件，就用 PEAR::Mail 這個就可以了，如果要搭配 html 網頁，就要搭上 PEAR::Mail_Mime</p>
<p><span id="more-129"></span><br />
接下來就是介紹怎麼安裝了，首先你的系統要有搭配 php pear 的套件</p>
<p>cd /usr/ports/devel/pear<br />
make install<br />
不過你如果裝 php5 的套件的話，她會順便一起裝進去，我想這不是重點</p>
<p>再來就是下載 PEAR::Mail 跟 PEAR::Mail_Mime 套件</p>
<p>其實作法很簡單，就是下載程式都丟到 includes 裡面，然後要用到的時候，利用底下</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><a href="http://www.php.net/define"><span class="kw3">define</span></a><span class="br0">&#40;</span><span class="st_h">'Document_root'</span><span class="sy0">,</span><a href="http://www.php.net/dirname"><span class="kw3">dirname</span></a><span class="br0">&#40;</span><span class="kw2">__FILE__</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<p>這個相當好用，取得絕對路徑，之後只要寫成下面底下就好</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">include</span><span class="br0">&#40;</span>Document_root <span class="sy0">.</span> <span class="st_h">'/includes/Mail.php'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">include</span><span class="br0">&#40;</span>Document_root <span class="sy0">.</span> <span class="st_h">'/includes/Mail/mime.php'</span><span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<p>再來是最普通的寄送範例：</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">include</span><span class="br0">&#40;</span>Document_root <span class="sy0">.</span> <span class="st_h">'/includes/Mail.php'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$recipients</span> <span class="sy0">=</span> <span class="st_h">'joe@example.com'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$headers</span><span class="br0">&#91;</span><span class="st_h">'From'</span><span class="br0">&#93;</span> &nbsp; &nbsp;<span class="sy0">=</span> <span class="st_h">'richard@phpguru.org'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$headers</span><span class="br0">&#91;</span><span class="st_h">'To'</span><span class="br0">&#93;</span> &nbsp; &nbsp; &nbsp;<span class="sy0">=</span> <span class="st_h">'joe@example.com'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$headers</span><span class="br0">&#91;</span><span class="st_h">'Subject'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'Test message'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$body</span> <span class="sy0">=</span> <span class="st_h">'Test message'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mail_object</span> <span class="sy0">=&amp;</span> <a href="http://www.php.net/mail"><span class="kw3">Mail</span></a><span class="sy0">::</span><span class="me2">factory</span><span class="br0">&#40;</span><span class="st_h">'mail'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mail_object</span><span class="sy0">-&gt;</span><span class="me1">send</span><span class="br0">&#40;</span><span class="re0">$recipients</span><span class="sy0">,</span> <span class="re0">$headers</span><span class="sy0">,</span> <span class="re0">$body</span><span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<p>裡面有一行<br />
$mail_object =&#038; Mail::factory(&#8217;mail&#8217;);<br />
這個有三種方式 mail, sendmail, smtp </p>
<p>mail: 這是不需要任何參數的<br />
sendmail:需要 sendmail 的程式路徑跟她所需要的參數<br />
smtp：需要 mail 主機位址，port，是否需要認證，帳號密碼之類的</p>
<p>當然我們用最普通的就好，那就是 mail 就可以，不過前提你要先架好 mail Server</p>
<p>Mail_Mime 的部分:</p>
<p>這部份比較複雜，我們先看範例：</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">include</span><span class="br0">&#40;</span>Document_root <span class="sy0">.</span> <span class="st_h">'/includes/Mail.php'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">include</span><span class="br0">&#40;</span>Document_root <span class="sy0">.</span> <span class="st_h">'/includes/Mail/mime.php'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$text</span> <span class="sy0">=</span> <span class="st_h">'我是小惡魔我是小惡魔我是小惡魔我是小惡魔'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$html</span> <span class="sy0">=</span> <span class="st_h">'&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &nbsp; &nbsp; &nbsp;&quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;<br />
&nbsp; &lt;html&gt;<br />
&nbsp; &lt;head&gt;<br />
&nbsp; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;<br />
&nbsp; &nbsp; &lt;title&gt;Hello World!&lt;/title&gt;<br />
&nbsp; &lt;/head&gt;<br />
&nbsp; &lt;body&gt;<br />
&nbsp; &lt;p&gt;Hello World!&lt;/p&gt;<br />
&nbsp; &lt;p&gt;我是小惡魔&lt;/p&gt;<br />
&nbsp; &lt;p&gt;我是小惡魔&lt;/p&gt;<br />
&nbsp; &lt;p&gt;我是小惡魔&lt;/p&gt;<br />
&nbsp; &lt;p&gt;我是小惡魔&lt;/p&gt;<br />
&nbsp; &lt;/body&gt;<br />
&nbsp; &lt;/html&gt;'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$file</span> <span class="sy0">=</span> <span class="st_h">'/home/appleboy/adwii/AB2.jpg'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$crlf</span> <span class="sy0">=</span> <span class="st0">&quot;<span class="es1">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$param</span><span class="br0">&#91;</span><span class="st_h">'text_charset'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'utf-8'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$param</span><span class="br0">&#91;</span><span class="st_h">'html_charset'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'utf-8'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$param</span><span class="br0">&#91;</span><span class="st_h">'head_charset'</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">'utf-8'</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$hdrs</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'From'</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="st_h">'appleboy@example.org'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Subject'</span> <span class="sy0">=&gt;</span> <span class="st_h">'系統資訊'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">'Content-type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'text/plain; charset=utf-8'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mime</span> <span class="sy0">=</span> <span class="kw2">new</span> Mail_mime<span class="br0">&#40;</span><span class="re0">$crlf</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">setTXTBody</span><span class="br0">&#40;</span><span class="re0">$text</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">setHTMLBody</span><span class="br0">&#40;</span><span class="re0">$html</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">addAttachment</span><span class="br0">&#40;</span><span class="re0">$file</span><span class="sy0">,</span> <span class="st_h">'text/plain'</span><span class="sy0">,</span> <span class="st_h">'AB2.jpg'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$body</span> <span class="sy0">=</span> <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">get</span><span class="br0">&#40;</span><span class="re0">$param</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$hdrs</span> <span class="sy0">=</span> <span class="re0">$mime</span><span class="sy0">-&gt;</span><span class="me1">headers</span><span class="br0">&#40;</span><span class="re0">$hdrs</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="co1">//echo $body;</span><br />
&nbsp; <span class="re0">$mail</span> <span class="sy0">=&amp;</span> <a href="http://www.php.net/mail"><span class="kw3">Mail</span></a><span class="sy0">::</span><span class="me2">factory</span><span class="br0">&#40;</span><span class="st_h">'mail'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$mail</span><span class="sy0">-&gt;</span><span class="me1">send</span><span class="br0">&#40;</span><span class="st_h">'appleboy@example.org'</span><span class="sy0">,</span> <span class="re0">$hdrs</span><span class="sy0">,</span> <span class="re0">$body</span><span class="br0">&#41;</span><span class="sy0">;</span></div></div>
<p>這個範例，可以附加檔案，跟寫 html 格式的 mail 寄信到對方<br />
$mime->addAttachment($file, &#8216;text/plain&#8217;, &#8216;AB2.jpg&#8217;);<br />
這一行就是寄送附加檔案，附加檔案的格式如下</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:580px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">function</span> addAttachment<span class="br0">&#40;</span><span class="re0">$file</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$c_type</span> &nbsp; &nbsp; &nbsp;<span class="sy0">=</span> <span class="st_h">'application/octet-stream'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$name</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="sy0">=</span> <span class="st_h">''</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$isfile</span> &nbsp; &nbsp; <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$encoding</span> &nbsp; &nbsp;<span class="sy0">=</span> <span class="st_h">'base64'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$disposition</span> <span class="sy0">=</span> <span class="st_h">'attachment'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$charset</span> &nbsp; &nbsp; <span class="sy0">=</span> <span class="st_h">''</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$language</span> &nbsp; <span class="sy0">=</span> <span class="st_h">''</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$location</span> &nbsp; &nbsp;<span class="sy0">=</span> <span class="st_h">''</span><span class="br0">&#41;</span></div></div>
<p>1.使用 Mail_mime() 建立新的 Mail_mime 物件(constructor)。<br />
  2.至少要使用 setTXTBody(), setHTMLBody(), addHTMLImage() 或 addAttachment()<br />
    四者其中之一建立內文或附檔。（當然通常的情況不只使用一個囉）<br />
  3.使用 get() 傳回內文。<br />
  4.使用 headers() 傳回檔頭。<br />
  5.利用傳回的內文與檔頭丟給 Mail::send() 送信。</p>
<p>reference</p>
<p><a href="http://pear.php.net/manual/en/package.mail.mail.intro.php">http://pear.php.net/manual/en/package.mail.mail.intro.php</a><br />
<a href="http://blog.xuite.net/noi1/yamesz/8928129">http://blog.xuite.net/noi1/yamesz/8928129</a><br />
<a href="http://pear.php.net/manual/en/package.mail.mail-mime.example.php">http://pear.php.net/manual/en/package.mail.mail-mime.example.php</a></p>
<h3>Related View</h3><ul class="related_post"><li><a href="http://blog.wu-boy.com/2008/10/01/524/" title="[PHP]解決 PEAR::Mail_Mime 標題 UTF-8 亂碼問題(不能顯示)">[PHP]解決 PEAR::Mail_Mime 標題 UTF-8 亂碼問題(不能顯示) (4)</a></li><li><a href="http://blog.wu-boy.com/2009/03/14/970/" title="[Windows] Appserv 安裝 pear 套件">[Windows] Appserv 安裝 pear 套件 (3)</a></li><li><a href="http://blog.wu-boy.com/2010/06/30/2254/" title="[phpBB3] BBCode [url] Tag 支援中文網址">[phpBB3] BBCode [url] Tag 支援中文網址 (1)</a></li><li><a href="http://blog.wu-boy.com/2010/06/23/2240/" title="[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9">[FreeBSD] update apache -> 2.2.15, PHP -> 5.3.2, and MySQL downgrade to 5.1.9 (0)</a></li><li><a href="http://blog.wu-boy.com/2010/06/13/2213/" title="[phpBB3 外掛] 根據使用者文章數目限制簽名檔顯示">[phpBB3 外掛] 根據使用者文章數目限制簽名檔顯示 (1)</a></li><li><a href="http://blog.wu-boy.com/2010/06/10/2203/" title="[教學] phpBB3 使用者簽名檔 url 連結加上 rel=&#8221;nofollow&#8221;  ">[教學] phpBB3 使用者簽名檔 url 連結加上 rel=&#8221;nofollow&#8221;   (1)</a></li><li><a href="http://blog.wu-boy.com/2010/06/07/2182/" title="[PHP] 好用 Debug PHP 工具 FirePHP for FireFox on CodeIgniter">[PHP] 好用 Debug PHP 工具 FirePHP for FireFox on CodeIgniter (0)</a></li><li><a href="http://blog.wu-boy.com/2010/03/21/2054/" title="[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇)">[FreeBSD]high performance caching reverse proxy: Varnish (安裝架設篇) (8)</a></li><li><a href="http://blog.wu-boy.com/2009/12/30/1920/" title="[PHP Framework] How to implement Plurk API in CodeIgniter">[PHP Framework] How to implement Plurk API in CodeIgniter (0)</a></li><li><a href="http://blog.wu-boy.com/2009/12/24/1913/" title="[PHP] Release 噗浪 php-plurk-api 1.2 Beta.">[PHP] Release 噗浪 php-plurk-api 1.2 Beta. (0)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.wu-boy.com/2007/12/18/129/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
