Пример #1
0
 public function sendMail($email = '', $name = '', $subject, $body, $key = 'gaodun')
 {
     if (!$email) {
         return FALSE;
     }
     //发送邮件的主要设置
     $mail = new PHPMailer(FALSE);
     $account = $this->setEmailAccount($key);
     try {
         $mail->IsSMTP();
         //启用smtp协议
         $mail->SMTPAuth = TRUE;
         $mail->SMTPKeepAlive = TRUE;
         $mail->CharSet = "utf-8";
         $mail->SMTPSecure = $account['md'];
         $mail->Port = $account['port'];
         $mail->Host = $account['host'];
         $mail->Username = $account['email'];
         $mail->Password = $account['pwd'];
         $mail->SetFrom($account['email'], '高顿实习');
         $mail->Subject = $subject;
         $mail->Body = $body;
         $mail->WordWrap = 50;
         // set word wrap
         $mail->MsgHTML($body);
         $mail->AddReplyTo('*****@*****.**', '高顿实习');
         $mail->AddAddress($email, $name ? $name : $email);
         //设置收件人
         $mail->IsHTML(TRUE);
         if ($mail->Send()) {
             $info = array('status' => TRUE, 'msg' => C('L_MAIL_SEND_SUCCESS'));
             // send as HTML
         } else {
             $info = array('status' => FALSE, 'msg' => $mail->ErrorInfo);
             // send as HTM
         }
         return $info;
     } catch (phpmailerException $e) {
         $info = array('status' => FALSE, 'msg' => $e->errorMessage());
         return $info;
     }
 }
Пример #2
0
 /**
  * 发送邮件
  * @author 致远<*****@*****.**>
  */
 public function sendMail($email, $subject, $body)
 {
     $mail = new PHPMailer(false);
     try {
         $mail->IsSMTP();
         $mail->SMTPAuth = true;
         $mail->SMTPKeepAlive = true;
         $mail->CharSet = "utf-8";
         $mail->SMTPSecure = $this->mail_Secure;
         $mail->Host = $this->mail_Host;
         $mail->Port = $this->mail_Port;
         $mail->Username = $this->mail_Username;
         $mail->Password = $this->mail_Password;
         $mail->From = $this->mail_Username;
         $mail->FromName = $this->mail_FromName;
         $mail->Subject = $subject;
         $mail->Body = $body;
         $mail->WordWrap = 50;
         $mail->MsgHTML($body);
         $mail->AddReplyTo($this->mail_Replymail, $this->mail_Replyname);
         $mail->AddAddress($email);
         $mail->IsHTML(true);
         if ($mail->Send()) {
             $info = array('status' => true, 'msg' => C('L_MAIL_SEND_SUCCESS'));
         } else {
             $info = array('status' => false, 'msg' => $mail->ErrorInfo);
         }
         return $info;
     } catch (phpmailerException $e) {
         $info = array('status' => false, 'msg' => $e->errorMessage());
         return $info;
     }
 }