PHP¢Óʼþ¿ÉÒÔÓÃÆa×Ô´ømail()º¯Êý,µ«ÊÇÕa¸oº¯ÊýºÜ²»ºÃʹ,ÐeÒªÅaÖÃÓʼþþÎñÆ÷£¬²¢ÇÒ²»Ö§³ÖsmtpÑeÖ¤£¬Ôںܶa³¡ºÏÎÞ¨Õý³£µÄ¹¤×÷. ÕÒÁ˸o´uÂe¢Óʼþ,µ«×ÜÊdzo´i,ÎÒÔÚÕaÀiÓÃPEARµÄMailÀa,ʹÓÃsmtp*¢Óʼþ.
Ê×ÏÈ°²×°,ÎÒÍƳÂÓÃ×iаaeµÄPHP5,ÒoΪÎÒÓÃPHP4³oÏÖÁ˺ܶaÎÊÌa,´o¶aÊÇÒoΪÄÇÐ(C)*a×°ºÃµÄÀa°ae±¾Ì«¸ß,ÓePHP4²»¼aeÈݵÄԹʰÉ.
°²×°½¨:
1.ÔÚphpĿ¼ÖÐË«»÷go-pear.bat¡£
2.°´ÕÕÌaʾÊaÈeÒ»Ð(C)ÉeÖÃÐÅÏ¢£¬Ö÷ÒªÊÇÎÊÖ±½ÓÃÎÊÍaÍø,»¹ÊÇÓôuÀi,ÈoÎÞ´uÀiþÎñÆ÷ÔoÖ±½Ó»Ø³µ,ÎÒÊÇÖ±½Ó°´»Ø³µ.
3.È»ºo»aÌaʾһÐ(C)°uºÍPHP°o¶¨£¬Ñ¡ÔñY ¡£
4.È»ºo°²×°»u±¾°uºÍÌaʾ°²×°³É¹¦£¬¾ÍÕaô¼oµ¥¡£
5.´o¿ªwindowsĿ¼ÏµÄphp.iniÎļþ£¬È»ºo²eÕÒµ½ÈçϵĵØ*½£º
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
°Ñ×iºoÒ»ÐеÄ×¢ÊÍÈ¥µo£¬È»ºo°ÑºoÃae¾¶¸Ä³ÉÄaµÄPEAR¾¶£¬ÀýÈ磺
include_path = ".;c:\php\pear\"
±£´aePHP.INI£¬È»ºoÖØÐÂÆo¶¯APACHE¼´¿É¡£
ÏÖÔÚPEARÒѾ°²ºÃÁË,ÎÒÃÇÒªÓõ½µÄÀa*ÅÔÚphpĿ¼ÏµÄpearÎļþ¼ÐÏÂ,µ«ÊÇÏÖÔÚûÓжaÉÙ¿ÉÓõÄÀa,ÎÒÃÇҪȥÍøÉÏÏÂÔز¢°²×°.
ÔÚÄaµÄPHP¸uĿ¼ÖпÉÒÔÕÒµ½PEAR.batÎļþ(Ö´ÐÐÉϱߵݲװ²Å»aÓÐÕa¸o¶«Î÷)£¬ÕaÊǹÜÀipearµÄÃuÁi£¬ÔÚCMDÖÐʹÓã¬ÒªÉeÖû¾³±aÁ¿PATH£¬»oË«»÷Éu³ÉµÄEV_XXX.REGÎļþ¡£ËuµÄ²¿ÖÃuÁi¹¦ÄÜÈçÏ£º
1¡¢°²Ñb£º
´ÓÍøÂç°²×°Ò»¸opearÀa¿a£º
¡¡¡¡pear install packagename
ÏÂÔØ packages µ«²»°²Ñb£º
¡¡¡¡pear download packagename
¡¡¡¡pear download-all
°²ÑbÒÑÏÂÔصÄpackage£º
¡¡¡¡pear install filename.tgz
2¡¢Áбi£º
Ä¿Ç°pearÍøÕ¾ÉÏËuÓпÉÈ¡µÃpearÀa¿aÁбi£º
¡¡¡¡pear remote-list
ÁгoÒÑ°²Ñbpackage£º
¡¡¡¡pear list
Áгo¿ÉÒÔÉý¼‰µÄpackage£º
¡¡¡¡pear list-upgrades
3¡¢¸uÐÂ(Éý¼‰)£º
¸uÐÂpackage£º
¡¡¡¡pear upgrade packagename
¡¡¡¡pear upgrade-all
4¡¢ÒƳý£º
„h³ýÒÑ°²ÑbµÄpackage£º
¡¡¡¡pear uninstall packagename
ÎÒÃÇ´Ócmd½øÈePHPĿ¼,Ö´ÐÐpear install mail
Èç¹u°²×°¹ý³ÌÌaʾijÐ(C)¿aûÓа²×°£¬Ôo¼ÌÐø°²×°ÕaÐ(C)¿aÈçͼ£º
Õa¼ÌÐø°²×°£º
³oÀ´Ò»Ð(C)ÐÅÏ¢,»aÌaʾ°²×°³É¹¦,ÕaʱpearĿ¼Ï¶a³oÀ´Ò»¸omailĿ¼,ͬʱÓÐÒ»¸omail.php,ÕaÊÇÎÒÃÇÒ»»aÒªÒýÓõÄÎļþ.
ϱßÊÇÎÒÃÇÓÃÀ´*¢ÓʼþµÄ´uÂe:
<?
require_once 'Mail.php';
flush();
$conf['mail'] = array(
'host' => 'mail.nenu.edu.cn', //smtp*þÎñÆ÷µØÖ*£¬¿ÉÒÔÓÃipµØÖ*»oÕßÓoÃu
'auth' => true, //true±iʾsmtp*þÎñÆ÷ÐeÒªÑeÖ¤£¬false´uÂe²»ÐeÒª
'username' => 'guanhf844', //Óû§Ãu
'password' => 'ÄaµÄÃÜÂe' //ÃÜÂe
);
$headers['From'] = 'guanhf844@nenu.edu.cn'; //*¢ÐŵØÖ*
$headers['To'] = 'chf007server@163.com'; //ÊÕÐŵØÖ*
$headers['Subject'] = 'test mail send by php'; //Óʼþ±eÌa
$mail_object = &Mail;::factory('smtp', $conf['mail']);
$body = '<<< MSG
hello world!!!
MSG';
//ÓʼþÕýÎÄ
$mail_res = $mail_object->send($headers['To'], $headers, $body); //*¢ËÍ
if( PEAR::isError($mail_res) ){ //¼i²a´iÎo
die($mail_res->getMessage());
}
echo 'Send finished.';
?>
¾²aÊÔ*¢Ëͳɹ¦,ËÙ¶Èͦ¿iµÄ,±ðµÄÓÊÏaûÓвaÊÔ¡£
ÒÔÉϾÍÊÇPHPʹÓÃpearʵÏÖmail*¢Ë͹¦ÄܵÄÈ«²¿´uÂe£¬Ï£Íu¶Ô´o¼ÒµÄѧϰÓÐËu°iÖu¡£