需要引用两个PHPmailer文件:PHPMailer.class.php SMTP.class.php
<?php
namespace Admin\Controller;
/**
* 其他控制器
*
* @author wangqiao
*/
class OtherController extends AdminController {
public function email(){
$this->display();
}
/*
* 邮件发送
*/
public function sends() {
if(IS_POST){
$tags = I('post.tags');
$content = I('post.content');
$title = I('post.title');
$subscribe = M('MeetSubscribe');
$list = $subscribe->where('type_id=%d',$tags)->field('email')->select();
$lists = array_column($list,'email');
$address = array_flip(array_flip($lists)); //获取订阅该类会议的邮箱,重复的邮箱不再重复取
$this->sendMail($address, $title, $content);
}
}
/*
* 邮件发送功能
*/
public function sendMail($address, $title, $content) {
$mail=new \Org\Util\PHPMailer();
$mail->CharSet = "utf-8"; //设置采用utf8中文编