require_once 'mail.php';
$conf['mail'] = array(
'host' => 'smtp.126.com', //smtp服务器地址
'auth' => true, //true表示smtp服务器需要验证,false不需要
'username' => 'liangbowen', //用户名
'password' => '******' //密码
);
//发送邮件
$headers['from'] = '[email protected]'; //发信地址
$headers['to'] = '[email protected]'; //收信地址
$headers['subject'] = 'test mail send by php bowen.mvbb.com'; //邮件标题
$mail_object = &mail::factory('smtp', $conf['mail']);
//邮件正文
$body = "这是一封自己发给自己的邮件。";
$mail_res = $mail_object->send($headers['to'], $headers, $body); //发送
if(pear::iserror($mail_res)){ //检测错误
die($mail_res->getmessage());
}
else{
echo "send successful!";
}
源码下载
http://down.111com.net/down/code/php/qitayuanma/2010/1220/22333.html