Пример #1
0
 /**
  * Read data from incoming stream.
  *
  * @return string  Line of data.
  *
  * @throws Horde_Smtp_Exception
  */
 public function read()
 {
     if (feof($this->_stream)) {
         $this->close();
         $this->_params['debug']->info("ERROR: Server closed the connection.");
         throw new Horde_Smtp_Exception(Horde_Smtp_Translation::r("Server closed the connection unexpectedly."), Horde_Smtp_Exception::DISCONNECT);
     }
     if (($read = fgets($this->_stream)) === false) {
         $this->_params['debug']->info("ERROR: Server read/timeout error.");
         throw new Horde_Smtp_Exception(Horde_Smtp_Translation::r("Error when communicating with the server."), Horde_Smtp_Exception::SERVER_READERROR);
     }
     $this->_params['debug']->server(rtrim($read, "\r\n"));
     return $read;
 }
Пример #2
0
 /**
  * Starts the TLS connection to the server, if necessary.  See RFC 3207.
  *
  * @return boolean  True if TLS was started.
  *
  * @throws Horde_Smtp_Exception
  */
 protected function _startTls()
 {
     $secure = $this->getParam('secure');
     if ($this->isSecureConnection() || $secure !== true && $secure !== 'tls') {
         return false;
     }
     if (!$this->queryExtension('STARTTLS')) {
         if ($secure === true) {
             return false;
         }
         throw new Horde_Smtp_Exception(Horde_Smtp_Translation::r("Server does not support TLS connections."), Horde_Smtp_Exception::LOGIN_TLSFAILURE);
     }
     $this->_connection->write('STARTTLS');
     $this->_getResponse(220, 'logout');
     if (!$this->_connection->startTls()) {
         $this->logout();
         $e = new Horde_Smtp_Exception();
         $e->setSmtpCode(454);
         throw $e;
     }
     $this->_debug->info('Successfully completed TLS negotiation.');
     $this->setParam('secure', 'tls');
     return true;
 }
Пример #3
0
 /**
  * Set the SMTP reply code.
  *
  * @param integer $code  SMTP reply code.
  */
 public function setSmtpCode($code)
 {
     $this->_smtpcode = $code;
     // Any code not listed here will get the details of the error message
     // as returned from the server.
     switch ($code) {
         case 450:
             $this->raw_msg = Horde_Smtp_Translation::r("Mailbox unavailable.");
             $this->message = Horde_Smtp_Translation::t($this->raw_msg);
             $this->code = self::MAILBOX_UNAVAILABLE;
             break;
         case 452:
             $this->raw_msg = Horde_Smtp_Translation::r("Insufficient system storage.");
             $this->message = Horde_Smtp_Translation::t($this->raw_msg);
             $this->code = self::INSUFFICIENT_STORAGE;
             break;
         case 454:
             $this->raw_msg = Horde_Smtp_Translation::r("Could not open secure TLS connection to the server.");
             $this->message = Horde_Smtp_Translation::t($this->raw_msg);
             $this->code = self::LOGIN_TLSFAILURE;
             break;
         case 530:
             $this->raw_msg = Horde_Smtp_Translation::r("Server requires authentication.");
             $this->message = Horde_Smtp_Translation::t($this->raw_msg);
             $this->code = self::LOGIN_REQUIREAUTHENTICATION;
             break;
         case 550:
             $this->raw_msg = Horde_Smtp_Translation::r("Message could not be delivered - the address was not found, is unknown, or is not receiving messages.");
             $this->message = Horde_Smtp_Translation::t($this->raw_msg);
             $this->code = self::MAILBOX_UNAVAILABLE;
             break;
         case 551:
             $this->code = self::UNKNOWN_LOCAL_USER;
             break;
         case 552:
             $this->code = self::OVERQUOTA;
             break;
         case 554:
             $this->raw_msg = Horde_Smtp_Translation::r("Server is not accepting SMTP connections.");
             $this->message = Horde_Smtp_Translation::t($this->raw_msg);
             $this->code = self::DISCONNECT;
             break;
     }
 }