Chinaunix首页 | 论坛 | 博客
  • 博客访问: 409259
  • 博文数量: 117
  • 博客积分: 5235
  • 博客等级: 大校
  • 技术积分: 1775
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-12 15:51
文章分类

全部博文(117)

文章存档

2012年(9)

2011年(2)

2010年(21)

2009年(13)

2008年(72)

我的朋友

分类:

2010-03-31 10:09:07

1. 简介
用脚本发送邮件
2. 发送
//setFrom函数中的邮箱必须与smtp服务器登录名相同,对于163是这样的,不然会发送失败
    $mail = new Zend_Mail('UTF-8');
  $mail->setBodyText('This is the text of the mail.');
  $mail->setFrom(, 'Some Sender');
  $mail->addTo(, 'Some Recipient');
  $mail->setSubject('TestSubject');
  $mail->send($mailTransport);
3. 发送服务器
3.1 sendmail
3.2 smtp
163邮箱设置
===
  $config = array(
   'auth' => 'login',
            'username' => 'abc',
            'password' => '11111111',
   'port' => 25,
   //'ssl' => 'ssl',
  );
  $mailTransport = new Zend_Mail_Transport_Smtp('smtp.163.com', $config);
  Zend_Mail::setDefaultTransport($mailTransport); //设置以后send()可以不用参数
4. 读取邮件
public function getmailAction(){
  $mail = new Zend_Mail_Storage_Pop3(array('host'     => 'pop3.163.com',
                                          'user'     => 'abc',
                                          'password' => '11111111'));
 
  echo $mail->countMessages() . " messages found
";
  foreach ($mail as $message) {
      echo "Mail from '{$message->from}': {$message->subject}
";
  }
  //$this->renderScript("index.phtml");
 }
阅读(468) | 评论(0) | 转发(0) |
0

上一篇:关于DateTime

下一篇:集成Smarty

给主人留下些什么吧!~~