v7‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT PKU\++ Abstract.phpnu[_validHost = new Am_Util_Dummy_Zend_Validate(); //$this->_validHost->addValidator(new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL)); if (!$this->_validHost->isValid($host)) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception(join(', ', $this->_validHost->getMessages())); } $this->_host = $host; $this->_port = $port; } /** * Class destructor to cleanup open resources * * @return void */ public function __destruct() { $this->_disconnect(); } /** * Set the maximum log size * * @param integer $maximumLog Maximum log size * @return void */ public function setMaximumLog($maximumLog) { $this->_maximumLog = (int) $maximumLog; } /** * Get the maximum log size * * @return int the maximum log size */ public function getMaximumLog() { return $this->_maximumLog; } /** * Create a connection to the remote host * * Concrete adapters for this class will implement their own unique connect scripts, using the _connect() method to create the socket resource. */ abstract public function connect(); /** * Retrieve the last client request * * @return string */ public function getRequest() { return $this->_request; } /** * Retrieve the last server response * * @return array */ public function getResponse() { return $this->_response; } /** * Retrieve the transaction log * * @return string */ public function getLog() { return implode('', $this->_log); } /** * Reset the transaction log * * @return void */ public function resetLog() { $this->_log = array(); } /** * Add the transaction log * * @param string new transaction * @return void */ protected function _addLog($value) { if ($this->_maximumLog >= 0 && count($this->_log) >= $this->_maximumLog) { array_shift($this->_log); } $this->_log[] = $value; } /** * Connect to the server using the supplied transport and target * * An example $remote string may be 'tcp://mail.example.com:25' or 'ssh://hostname.com:2222' * * @param string $remote Remote * @throws Zend_Mail_Protocol_Exception * @return boolean */ protected function _connect($remote) { $errorNum = 0; $errorStr = ''; // open connection $this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION); if ($this->_socket === false) { if ($errorNum == 0) { $errorStr = 'Could not open socket'; } /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($errorStr); } if (($result = $this->_setStreamTimeout(self::TIMEOUT_CONNECTION)) === false) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Could not set stream timeout'); } return $result; } /** * Disconnect from remote host and free resource * * @return void */ protected function _disconnect() { if (is_resource($this->_socket)) { fclose($this->_socket); } } /** * Send the given request followed by a LINEEND to the server. * * @param string $request * @throws Zend_Mail_Protocol_Exception * @return integer|boolean Number of bytes written to remote host */ protected function _send($request) { if (!is_resource($this->_socket)) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host); } $this->_request = $request; $result = fwrite($this->_socket, $request . self::EOL); // Save request to internal log $this->_addLog($request . self::EOL); if ($result === false) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Could not send request to ' . $this->_host); } return $result; } /** * Get a line from the stream. * * @var integer $timeout Per-request timeout value if applicable * @throws Zend_Mail_Protocol_Exception * @return string */ protected function _receive($timeout = null) { if (!is_resource($this->_socket)) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host); } // Adapters may wish to supply per-commend timeouts according to appropriate RFC if ($timeout !== null) { $this->_setStreamTimeout($timeout); } // Retrieve response $reponse = fgets($this->_socket, 1024); // Save request to internal log $this->_addLog($reponse); // Check meta data to ensure connection is still valid $info = stream_get_meta_data($this->_socket); if (!empty($info['timed_out'])) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($this->_host . ' has timed out'); } if ($reponse === false) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Could not read from ' . $this->_host); } return $reponse; } /** * Parse server response for successful codes * * Read the response from the stream and check for expected return code. * Throws a Zend_Mail_Protocol_Exception if an unexpected code is returned. * * @param string|array $code One or more codes that indicate a successful response * @throws Zend_Mail_Protocol_Exception * @return string Last line of response string */ protected function _expect($code, $timeout = null) { $this->_response = array(); $cmd = ''; $more = ''; $msg = ''; $errMsg = ''; if (!is_array($code)) { $code = array($code); } do { $this->_response[] = $result = $this->_receive($timeout); list($cmd, $more, $msg) = preg_split('/([\s-]+)/', $result, 2, PREG_SPLIT_DELIM_CAPTURE); if ($errMsg !== '') { $errMsg .= ' ' . $msg; } elseif ($cmd === null || !in_array($cmd, $code)) { $errMsg = $msg; } } while (strpos($more, '-') === 0); // The '-' message prefix indicates an information string instead of a response string. if ($errMsg !== '') { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($errMsg, $cmd); } return $msg; } /** * Set stream timeout * * @param integer $timeout * @return boolean */ protected function _setStreamTimeout($timeout) { return stream_set_timeout($this->_socket, $timeout); } } PKU\л} } Smtp/Auth/Plain.phpnu[_username = $config['username']; } if (isset($config['password'])) { $this->_password = $config['password']; } } parent::__construct($host, $port, $config); } /** * Perform PLAIN authentication with supplied credentials * * @return void */ public function auth() { // Ensure AUTH has not already been initiated. parent::auth(); $this->_send('AUTH PLAIN'); $this->_expect(334); $this->_send(base64_encode("\0" . $this->_username . "\0" . $this->_password)); $this->_expect(235); $this->_auth = true; } } PKU\=Ӱ Smtp/Auth/Login.phpnu[_username = $config['username']; } if (isset($config['password'])) { $this->_password = $config['password']; } } parent::__construct($host, $port, $config); } /** * Perform LOGIN authentication with supplied credentials * * @return void */ public function auth() { // Ensure AUTH has not already been initiated. parent::auth(); $this->_send('AUTH LOGIN'); $this->_expect(334); $this->_send(base64_encode($this->_username)); $this->_expect(334); $this->_send(base64_encode($this->_password)); $this->_expect(235); $this->_auth = true; } } PKU\ꗼ/ / Smtp/Auth/Crammd5.phpnu[_username = $config['username']; } if (isset($config['password'])) { $this->_password = $config['password']; } } parent::__construct($host, $port, $config); } /** * @todo Perform CRAM-MD5 authentication with supplied credentials * * @return void */ public function auth() { // Ensure AUTH has not already been initiated. parent::auth(); $this->_send('AUTH CRAM-MD5'); $challenge = $this->_expect(334); $challenge = base64_decode($challenge); $digest = $this->_hmacMd5($this->_password, $challenge); $this->_send(base64_encode($this->_username . ' ' . $digest)); $this->_expect(235); $this->_auth = true; } /** * Prepare CRAM-MD5 response to server's ticket * * @param string $key Challenge key (usually password) * @param string $data Challenge data * @param string $block Length of blocks * @return string */ protected function _hmacMd5($key, $data, $block = 64) { if (strlen($key) > 64) { $key = pack('H32', md5($key)); } elseif (strlen($key) < 64) { $key = str_pad($key, $block, "\0"); } $k_ipad = substr($key, 0, 64) ^ str_repeat(chr(0x36), 64); $k_opad = substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64); $inner = pack('H32', md5($k_ipad . $data)); $digest = md5($k_opad . $inner); return $digest; } } PKU\hch.h.Smtp.phpnu[_secure = 'tls'; break; case 'ssl': $this->_transport = 'ssl'; $this->_secure = 'ssl'; if ($port == null) { $port = 465; } break; default: /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception($config['ssl'] . ' is unsupported SSL type'); break; } } // If no port has been specified then check the master PHP ini file. Defaults to 25 if the ini setting is null. if ($port == null) { if (($port = ini_get('smtp_port')) == '') { $port = 25; } } parent::__construct($host, $port); } /** * Connect to the server with the parameters given in the constructor. * * @return boolean */ public function connect() { return $this->_connect($this->_transport . '://' . $this->_host . ':'. $this->_port); } /** * Initiate HELO/EHLO sequence and set flag to indicate valid smtp session * * @param string $host The client hostname or IP address (default: 127.0.0.1) * @throws Zend_Mail_Protocol_Exception * @return void */ public function helo($host = '127.0.0.1') { // Respect RFC 2821 and disallow HELO attempts if session is already initiated. if ($this->_sess === true) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Cannot issue HELO to existing session'); } // Validate client hostname if (!$this->_validHost->isValid($host)) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception(join(', ', $this->_validHost->getMessages())); } // Initiate helo sequence $this->_expect(220, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 $this->_ehlo($host); // If a TLS session is required, commence negotiation if ($this->_secure == 'tls') { $this->_send('STARTTLS'); $this->_expect(220, 180); if (!stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Unable to connect via TLS'); } $this->_ehlo($host); } $this->_startSession(); $this->auth(); } /** * Send EHLO or HELO depending on capabilities of smtp host * * @param string $host The client hostname or IP address (default: 127.0.0.1) * @throws Zend_Mail_Protocol_Exception * @return void */ protected function _ehlo($host) { // Support for older, less-compliant remote servers. Tries multiple attempts of EHLO or HELO. try { $this->_send('EHLO ' . $host); $this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 } catch (Zend_Mail_Protocol_Exception $e) { $this->_send('HELO ' . $host); $this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 } catch (Zend_Mail_Protocol_Exception $e) { throw $e; } } /** * Issues MAIL command * * @param string $from Sender mailbox * @throws Zend_Mail_Protocol_Exception * @return void */ public function mail($from) { if ($this->_sess !== true) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('A valid session has not been started'); } $this->_send('MAIL FROM:<' . $from . '>'); $this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 // Set mail to true, clear recipients and any existing data flags as per 4.1.1.2 of RFC 2821 $this->_mail = true; $this->_rcpt = false; $this->_data = false; } /** * Issues RCPT command * * @param string $to Receiver(s) mailbox * @throws Zend_Mail_Protocol_Exception * @return void */ public function rcpt($to) { if ($this->_mail !== true) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No sender reverse path has been supplied'); } // Set rcpt to true, as per 4.1.1.3 of RFC 2821 $this->_send('RCPT TO:<' . $to . '>'); $this->_expect(array(250, 251), 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 $this->_rcpt = true; } /** * Issues DATA command * * @param string $data * @throws Zend_Mail_Protocol_Exception * @return void */ public function data($data) { // Ensure recipients have been set if ($this->_rcpt !== true) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('No recipient forward path has been supplied'); } $this->_send('DATA'); $this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2 foreach (explode(Zend_Mime::LINEEND, $data) as $line) { if (strpos($line, '.') === 0) { // Escape lines prefixed with a '.' $line = '.' . $line; } $this->_send($line); } $this->_send('.'); $this->_expect(250, 600); // Timeout set for 10 minutes as per RFC 2821 4.5.3.2 $this->_data = true; } /** * Issues the RSET command and validates answer * * Can be used to restore a clean smtp communication state when a transaction has been cancelled or commencing a new transaction. * * @return void */ public function rset() { $this->_send('RSET'); // MS ESMTP doesn't follow RFC, see [ZF-1377] $this->_expect(array(250, 220)); $this->_mail = false; $this->_rcpt = false; $this->_data = false; } /** * Issues the NOOP command and validates answer * * Not used by Zend_Mail, could be used to keep a connection alive or check if it is still open. * * @return void */ public function noop() { $this->_send('NOOP'); $this->_expect(250, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 } /** * Issues the VRFY command and validates answer * * Not used by Zend_Mail. * * @param string $user User Name or eMail to verify * @return void */ public function vrfy($user) { $this->_send('VRFY ' . $user); $this->_expect(array(250, 251, 252), 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 } /** * Issues the QUIT command and clears the current session * * @return void */ public function quit() { if ($this->_sess) { $this->_send('QUIT'); $this->_expect(221, 300); // Timeout set for 5 minutes as per RFC 2821 4.5.3.2 $this->_stopSession(); } } /** * Default authentication method * * This default method is implemented by AUTH adapters to properly authenticate to a remote host. * * @throws Zend_Mail_Protocol_Exception * @return void */ public function auth() { if ($this->_auth === true) { /** * @see Zend_Mail_Protocol_Exception */ //--//require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception('Already authenticated for this session'); } } /** * Closes connection * * @return void */ public function disconnect() { $this->_disconnect(); } /** * Start mail session * * @return void */ protected function _startSession() { $this->_sess = true; } /** * Stop mail session * * @return void */ protected function _stopSession() { $this->_sess = false; } } PKU\{#4WW Exception.phpnu[