PHP使用Zend Mail发送邮件

<?php require_once 'Zend/Mail.php'; require_once 'Zend/Mail/Transport/Smtp.php'; class logMail { private static $_config=array('auth'=>'login', 'username'=>'xx@xx.xx',//发送使用的邮箱 'password'=>'xx'); //发送使用的邮箱的登录密码 private static $_mail = null; private static $_transport = null; public function __construct($title, $body,$address)//参数为邮件的主题,内容和地址 { try { $transport = new Zend_Mail_Transport_Smtp('smtp.xx.xx',self::$_config); //发送的SMTP服务器地址 $mail = new Zend_Mail('GBK'); //实例化发送邮件对象 $mail->setBodyHtml($body); //发送邮件的主体 $mail->setFrom('xx@xx.xx', ''); //定义邮件发送使用的邮箱 $mail->addTo("$address", 'xx@xx.xx'); //定义邮件的接收邮箱 $mail->setSubject($title); //定义邮件主题 $mail->send($transport); //执行发送操作 return true; } catch(Exception $e) { $e->getTrace(); return false; } return false; } public static function logMail($title, $body,$address) { $this->__construct($title, $body,$address); } } if (new logMail('Test Mail','Test Content',"xx@xx.xx")) { echo "发送成功"; } else { echo "发送失败"; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值