Author: Michael Slusarz (slusarz@horde.org)
Inheritance: extends Horde_Translation_Autodetect
Exemplo n.º 1
0
 /**
  * Set the SMTP reply code.
  *
  * @param integer $smtpcode  SMTP reply code.
  */
 public function setSmtpCode($smtpcode)
 {
     $this->_enhancedcode = null;
     $this->code = 0;
     $this->_smtpcode = $smtpcode;
     /* Any code not listed here will get the details of the error message
      * as returned from the server.
      * Need to store $code/$message here because getCode()/getMessage() is
      * declared final in the parent class and we can not alter on-demand
      * at that location (darn). */
     switch ($smtpcode) {
         case 450:
             $this->code = self::MAILBOX_UNAVAILABLE;
             $this->message = Horde_Smtp_Translation::t("Mailbox unavailable.");
             return;
         case 452:
             $this->code = self::INSUFFICIENT_STORAGE;
             $this->message = Horde_Smtp_Translation::t("Insufficient system storage.");
             return;
         case 454:
             $this->code = self::LOGIN_TLSFAILURE;
             $this->message = Horde_Smtp_Translation::t("Could not open secure TLS connection to the server.");
             return;
         case 530:
             $this->code = self::LOGIN_REQUIREAUTHENTICATION;
             $this->message = Horde_Smtp_Translation::t("Server requires authentication.");
             return;
         case 550:
             $this->code = self::MAILBOX_UNAVAILABLE;
             $this->message = Horde_Smtp_Translation::t("Message could not be delivered - the address was not found, is unknown, or is not receiving messages.");
             return;
         case 551:
             $this->code = self::UNKNOWN_LOCAL_USER;
             return;
         case 552:
             $this->code = self::OVERQUOTA;
             return;
         case 554:
             $this->code = self::DISCONNECT;
             $this->message = Horde_Smtp_Translation::t("Server is not accepting SMTP connections.");
             return;
     }
     $str_code = strval($smtpcode);
     switch ($str_code[1]) {
         case '0':
             $this->code = self::CATEGORY_SYNTAX;
             break;
         case '1':
             $this->code = self::CATEGORY_INFORMATIONAL;
             break;
         case '2':
             $this->code = self::CATEGORY_CONNECTIONS;
             break;
         case '5':
             $this->code = self::CATEGORY_MAILSYSTEM;
             break;
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
 /**
  * Returns the plural translation of a message.
  *
  * @param string $singular  The singular version to translate.
  * @param string $plural    The plural version to translate.
  * @param integer $number   The number that determines singular vs. plural.
  *
  * @return string  The string translation, or the original string if no
  *                 translation exists.
  */
 public static function ngettext($singular, $plural, $number)
 {
     self::$_domain = 'Horde_Smtp';
     self::$_directory = '@data_dir@' == '@' . 'data_dir' . '@' ? __DIR__ . '/../../../locale' : '@data_dir@/Horde_Smtp/locale';
     return parent::ngettext($singular, $plural, $number);
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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;
     }
 }