php PEAR mail发送邮件实例
时间:2014-06-09 16:40来源: 作者: 点击:
次
phppear mail发送邮件实例 -- !doctypehtml public -//w3c//dtdxhtml1.0transitional//en http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd htmlxmlns= http://www.w3.org/1999/xhtml head metahttp-equiv= content-type content= text/html;charset=gb2
phppear mail发送邮件实例
- -->
- <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=gb2312" />
- <title>php发送邮件</title>
- </head>
- <body>
- <table width="611" height="200" border="1">
- <tr>
- <td width="601"><form id="form1" name="form1" method="post" action="send.php">
- <table width="600" height="240" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="102" height="28">收件人地址</td>
- <td width="213"><input name="to" type="text" id="to" /></td>
- <td width="84">发送人地址</td>
- <td width="201"><input name="from" type="text" id="from" value="cert@163.com" /></td>
- </tr>
- <tr>
- <td height="33">发送人用户名</td>
- <td><input name="name" type="text" id="username" value="cert" /></td>
- <td>邮箱密码</td>
- <td><input name="password" type="password" id="password" value="***" /></td>
- </tr>
- <tr>
- <td height="27">smtp服务器</td>
- <td><input name="smtp" type="text" id="smtp" value="smtp.163.com" /></td>
- <td colspan="2">注:163邮箱smtp为: smtp.163.com</td>
- </tr>
- <tr>
- <td height="26">标题</td>
- <td colspan="3"><input name="subject" type="text" id="subject" value="cert测试php发送邮件" size="50" /></td>
- </tr>
- <tr>
- <td height="69">内容</td>
- <td colspan="3"><textarea name="content" cols="50" rows="6" id="content">计算机紧急响应组欢迎你!
- http:
- 组织网站即将进行改版</textarea></td>
- </tr>
- <tr>
-
- <td> </td>
- <td align="right"><input type="submit" name="submit" value="发送" /></td>
- <td> </td>
- <td> </td>
- </tr>
- </table>
- <p>说明:我用163的邮箱发给 163 或 126 的邮箱立刻就能收到。大家试试。</p>
- </form>
- </td>
- </tr>
- </table>
- </body>
- </html>
- <?
- require_once 'mail.php';
- $conf['mail'] = array(
- 'host' => 'smtp.126.com',
- 'auth' => true,
- '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!";
- }
(责任编辑:admin) |
------分隔线----------------------------