File indexing completed on 2025-03-02 05:29:34
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Mail 0017 * @subpackage Protocol 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 0024 /** 0025 * @see Zend_Mail_Protocol_Smtp 0026 */ 0027 // require_once 'Zend/Mail/Protocol/Smtp.php'; 0028 0029 0030 /** 0031 * Performs LOGIN authentication 0032 * 0033 * @category Zend 0034 * @package Zend_Mail 0035 * @subpackage Protocol 0036 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0037 * @license http://framework.zend.com/license/new-bsd New BSD License 0038 */ 0039 class Zend_Mail_Protocol_Smtp_Auth_Login extends Zend_Mail_Protocol_Smtp 0040 { 0041 /** 0042 * LOGIN username 0043 * 0044 * @var string 0045 */ 0046 protected $_username; 0047 0048 0049 /** 0050 * LOGIN password 0051 * 0052 * @var string 0053 */ 0054 protected $_password; 0055 0056 0057 /** 0058 * Constructor. 0059 * 0060 * @param string $host (Default: 127.0.0.1) 0061 * @param int $port (Default: null) 0062 * @param array $config Auth-specific parameters 0063 * @return void 0064 */ 0065 public function __construct($host = '127.0.0.1', $port = null, $config = null) 0066 { 0067 if (is_array($config)) { 0068 if (isset($config['username'])) { 0069 $this->_username = $config['username']; 0070 } 0071 if (isset($config['password'])) { 0072 $this->_password = $config['password']; 0073 } 0074 } 0075 0076 parent::__construct($host, $port, $config); 0077 } 0078 0079 0080 /** 0081 * Perform LOGIN authentication with supplied credentials 0082 * 0083 * @return void 0084 */ 0085 public function auth() 0086 { 0087 // Ensure AUTH has not already been initiated. 0088 parent::auth(); 0089 0090 $this->_send('AUTH LOGIN'); 0091 $this->_expect(334); 0092 $this->_send(base64_encode($this->_username)); 0093 $this->_expect(334); 0094 $this->_send(base64_encode($this->_password)); 0095 $this->_expect(235); 0096 $this->_auth = true; 0097 } 0098 }