setSmtpCode() public méthode

Set the SMTP reply code.
public setSmtpCode ( integer $smtpcode )
$smtpcode integer SMTP reply code.
Exemple #1
0
 /**
  */
 protected function _processData($recipients)
 {
     /* RFC 2033 [4.2/4.3]: there is one response for each successful
      * recipient, so need to iterate through the array. If no successful
      * recipients found, throw an exception. */
     $out = array();
     $success = false;
     foreach ($recipients as $val) {
         try {
             $this->_getResponse(250);
             $out[$val] = $success = true;
         } catch (Horde_Smtp_Exception $e) {
             $out[$val] = $e;
         }
     }
     if (!$success) {
         $e = new Horde_Smtp_Exception('Sending to all recipients failed.');
         $e->setSmtpCode(550);
         throw $e;
     }
     return $out;
 }
Exemple #2
0
 /**
  * Gets a line from the incoming stream and parses it.
  *
  * @param mixed $code    Expected reply code(s) (integer or array).
  * @param string $error  On error, 'logout' or 'reset'?
  *
  * @return array  An array with the response text.
  * @throws Horde_Smtp_Exception
  */
 protected function _getResponse($code, $error = null)
 {
     $text = array();
     while ($read = $this->_connection->read()) {
         $read = trim(rtrim($read, "\r\n"));
         $replycode = intval(substr($read, 0, 3));
         $text[] = ltrim(substr($read, 4));
         if ($read[3] != '-') {
             break;
         }
     }
     if (!is_array($code)) {
         $code = array($code);
     }
     if (in_array($replycode, $code)) {
         return $text;
     }
     /* Check for enhanced status codes (RFC 2034). */
     $details = reset($text);
     if (!is_null($this->_extensions) && $this->queryExtension('ENHANCEDSTATUSCODES')) {
         list($enhanced, $details) = explode(' ', $details, 2);
     } else {
         $enhanced = null;
     }
     $e = new Horde_Smtp_Exception($details);
     $e->details = $details;
     $e->setSmtpCode($replycode);
     $e->setEnhancedSmtpCode($enhanced);
     switch ($error) {
         case 'logout':
             $this->logout();
             break;
         case 'reset':
             /* RFC 3207: If we see 530, no need to send reset command. */
             if ($code != 530) {
                 $this->resetCmd();
             }
             break;
     }
     throw $e;
 }
Exemple #3
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, array('error' => '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;
 }