コード例 #1
0
ファイル: PwMail.php プロジェクト: fanqimeng/4tweb
 /**
  * 普通发邮件方法
  *
  * @param string $toUser 收件人
  * @param string $subject 邮件标题
  * @param string $content 邮件内容
  * @return bool
  */
 public function sendMail($toUser, $subject, $content)
 {
     if (!$this->_config['mailOpen']) {
         return new PwError('ADMIN:email.close');
     }
     $this->_mail->setSubject($subject);
     $this->_mail->setTo($toUser);
     $this->_mail->setBody($content);
     try {
         $rt = $this->_mail->send($this->getMethod(), $this->_config);
         if (false === $rt) {
             return new PwError('ADMIN:email.server.error');
         }
     } catch (Exception $e) {
         //TODO 邮件发送失败
         // 			return new PwError($e->getMessage());
         return new PwError('ADMIN:email.server.error');
     }
     return true;
 }
コード例 #2
0
ファイル: PwMail.php プロジェクト: ccq18/EduSoho
 /**
  * 普通发邮件方法
  *
  * @param string $toUser 收件人
  * @param string $subject 邮件标题
  * @param string $content 邮件内容
  * @return bool
  */
 public function sendMail($toUser, $subject, $content)
 {
     if (!$this->_config['mailOpen']) {
         return new PwError('ADMIN:email.close');
     }
     $this->_mail->setSubject($subject);
     $this->_mail->setTo($toUser);
     $this->_mail->setBody($content);
     try {
         $rt = $this->_mail->send($this->getMethod(), $this->_config);
         if (false === $rt) {
             return new PwError('ADMIN:email.server.error');
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         if (strpos($message, 'Initiates a socket connection fail')) {
             $message = 'ADMIN:email.server.config.error';
         } elseif (strpos($message, '[mail.protocol.WindSmtp.checkResponse]')) {
             $message = 'ADMIN:email.server.response.error';
         }
         return new PwError($message);
     }
     return true;
 }