if ($nodeInfo['mail_notice'] == 1) { $email = $user['email']; if (!$email) continue 1; //是否使用模板 if($data['is_template']) { $data = $this->parseTemplate($node,'mail', $data); } #系统消息设置中心调用,临时实现company 发邮件,后期模块上线后请修改 @liliang if(!$user['id'])continue 1; $company = D("UserCompany",'user')->getByField(array('user_id'=>$user['id'])); $email = $company['email']; $this->sendEmail($user['id'],$email,$user['username'],$data['title'],$data['body'],'system_mail',$queue); } /** * 发送邮件,添加到消息队列数据表中 * @param array $data 消息的相关数据 * @param array $queue 是否队列放松 * @param unknown $userId * @param array $email 要发送的邮件 * @param unknown $title * @param unknown $body * @param string $node * @param array $mailParam 邮件配置 * @return boolean */ public function sendEmail($userId,$email,$name,$title, $body, $node='register_user',$queue=0) { if(empty($email)) { return false; } $data['user_id'] = $userId; $data['node'] = $node; $data['email'] = $email; $data['username'] = $name; $data['is_send'] = $data['send_time'] = 0; $data['title'] = $title; $data['body']= html_entity_decode($body); if ($queue == 1) { return D('NotifyEmail','notify')->add($data); //插入邮件群发队列 } else { return D('NotifyEmail','notify')->sendSysMail($data); } } /** * 发送全局邮件 * Enter description here ... * @param unknown_type $data */ public function sendSysMail($data){ #$this->config 请取出全局配置 $email = array($data['email']=>$data['username']); $email_cc = array('guoqi@aixintrip.com'=>'琪琪','caorui@aixintrip.com'=>'曹睿','chenshichao@aixintrip.com'=>'士超'); initPHP::import('library/plugin/PHPMailer/PHPMailerAutoload.php'); $this->mailParam = array('CharSet'=>$this->CharSet, 'Port'=>$this->Port, 'Host'=>$this->Host, 'From'=>$this->From, 'FromName'=>$this->FromName, 'SMTPAuth'=>$this->SMTPAuth, 'Username'=>$this->Username, 'Password'=>$this->Password, 'SMTPSecure'=>$this->SMTPSecure); $mail = new PHPMailer; $mail->isSMTP(); $mail->isHTML(true);// Set email format to HTML $mail->SMTPDebug = $this->SMTPDebug; while (list($key, $val) = each($this->mailParam)) { $mail->$key = $val; } while (list($m, $n) = each($email)) { $mail->addAddress($m, $n); // Add a recipient } while (list($m, $n) = each($email_cc)) { $mail->addCC($m, $n); // Add a recipient } $mail->addBCC('21720162@qq.com'); // 添加密送者,Mail Header不会显示密送者信息 $mail->ConfirmReadingTo = 'liliang@aixintrip.com'; // 添加发送回执邮件地址,即当收件人打开邮件后,会询问是否发生回执 $mail->addReplyTo('no-reply@aixingtrip.com', '请勿回复'); $mail->Subject = $data['title']; $mail->Body = $data['body']; $mail->AltBody = strip_tags($data['body']);#不支持html时显示该信息 if(!$mail->send()) { return false; }else{ return true; } }