thinkphp发送邮件的类

使用方法:

  1. import('ORG.Net.Email');
  2.         $emailer = new Email();
  3.         $emailer->setConfig('smtp_host', $this->config['smtp_host']);
  4.         $emailer->setConfig('smtp_user', $this->config['smtp_user']);
  5.         $emailer->setConfig('smtp_pass', $this->config['smtp_pass']);
  6.         $emailer->setConfig('from', $this->config['guestbook']);
  7.         $emailer->setConfig('charset', 'UTF-8');
  8.         
  9.         $emailer->sendTo = $this->config['guestbook'];
  10.         $emailer->subject = auto_charset("(网站留言){$_POST['title']}", 'utf-8', 'gb2312');
  11.         
  12.         /** 必填字段信息 */
  13.         $emailer->content  = "<strong>{$_POST['title']}</strong>";
  14.         $emailer->content .= "<p>{$_POST['content']}</p>";
  15.         $emailer->content .= "{$space}移动电话:{$_POST['mobile']}({$_POST['name']})";
  16.         
  17.         /** 选填字段信息 */
  18.         $emailer->content .= "{$space}电子邮件:{$_POST['email']}";
  19.         $emailer->content .= "{$space}座机号码:{$_POST['phone']}";
  20.         $emailer->content .= "{$space}传真号码:{$_POST['fax']}";
  21.         $emailer->content .= "{$space}QQ:{$_POST['qq']}";
  22.         $emailer->content .= "{$space}MSN:{$_POST['msn']}";
  23.         
  24.         $result = $emailer->send();
  25.         if(true == $result){echo '邮件发送成功!'}else{echo $result;}
复制代码

目前已经在163.com , 21cn.com, tom.com 及部分企业邮局上测试通过。
不知道对大家有没有用?

 

点击下载: Email_class.rar

thinkphp  发送邮件  
Trackback

本文到目前为止有0条评论

添加评论