Esempio n. 1
0
 /**
  * @param WindMail $mail 
  * @see IWindSendMail::send()
  */
 public function send($mail, $config = array())
 {
     if ($this->smtp === null) {
         $this->_init($config);
         $this->smtp = new WindSmtp($this->host, $this->port, $this->timeout);
     }
     $this->smtp->open();
     $this->smtp->ehlo($this->name);
     if ($this->auth) {
         $this->smtp->authLogin($this->username, $this->password);
     }
     $this->smtp->mailFrom($mail->getFrom());
     foreach ($mail->getRecipients() as $rcpt) {
         $this->smtp->rcptTo($rcpt);
     }
     $this->smtp->data($mail->createHeader() . $mail->createBody());
     $this->smtp->quit();
     return true;
 }
Esempio n. 2
0
 /**
  * 普通发邮件方法
  *
  * @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;
 }
Esempio n. 3
0
 /**
  * 普通发邮件方法
  *
  * @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;
 }