封装了一个TP发送邮件的类

import('ORG.Net.Email');
        $emailer = new Email();
        $emailer->setConfig('smtp_host', $this->config['smtp_host']);
        $emailer->setConfig('smtp_user', $this->config['smtp_user']);
        $emailer->setConfig('smtp_pass', $this->config['smtp_pass']);
        $emailer->setConfig('from', $this->config['guestbook']);
        $emailer->setConfig('charset', 'UTF-8');
        
        $emailer->sendTo = $this->config['guestbook'];
        $emailer->subject = auto_charset("(网站留言){$_POST['title']}", 'utf-8', 'gb2312');
        
        /** 必填字段信息 */
        $emailer->content  = "<strong>{$_POST['title']}</strong>";
        $emailer->content .= "<p>{$_POST['content']}</p>";
        $emailer->content .= "{$space}移动电话:{$_POST['mobile']}({$_POST['name']})";
        
        /** 选填字段信息 */
        $emailer->content .= "{$space}电子邮件:{$_POST['email']}";
        $emailer->content .= "{$space}座机号码:{$_POST['phone']}";
        $emailer->content .= "{$space}传真号码:{$_POST['fax']}";
        $emailer->content .= "{$space}QQ:{$_POST['qq']}";
        $emailer->content .= "{$space}MSN:{$_POST['msn']}";
        
        $result = $emailer->send();
        if(true == $result){echo '邮件发送成功!'}else{echo $result;}


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

Email_class.rar

1.01 KB, 下载次数: 874

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值