php PEAR mail发送邮件实例
phppear mail发送邮件实例
- -->
- public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
- "http://www.w3.org/1999/xhtml">
- "content-type" content="text/html; charset=gb2312" />
php发送邮件 "611" height="200" border="1">
"601"> "600" height="240" border="0" cellpadding="0" cellspacing="0">
"102" height="28">收件人地址 "213">"to" type="text" id="to" /> "84">发送人地址 "201">"from" type="text" id="from" value="cert@163.com" /> "33">发送人用户名 "name" type="text" id="username" value="cert" /> 邮箱密码 "password" type="password" id="password" value="***" /> "27">smtp服务器 "smtp" type="text" id="smtp" value="smtp.163.com" /> "2">注:163邮箱smtp为: smtp.163.com "26">标题 "3">"subject" type="text" id="subject" value="cert测试php发送邮件" size="50" /> "69">内容 "3"> - http://www.phpfensi.com
- 组织网站即将进行改版
"right">"submit" name="submit" value="发送" /> 说明:我用163的邮箱发给 163 或 126 的邮箱立刻就能收到。大家试试。
- require_once 'mail.php';
- $conf['mail'] = array(
- 'host' => 'smtp.126.com', //smtp服务器地址
- 'auth' => true, //true表示smtp服务器需要验证,false不需要
- 'username' => 'liangbowen', //用户名
- 'password' => '******' //密码
- );
- //发送邮件
- $headers['from'] = 'liangbowen@126.com'; //发信地址
- $headers['to'] = 'liangbowen@hotmail.com'; //收信地址
- $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!";
- }

