Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Mail / Protocol / Smtp / Auth / Login.php
blobbcc2c8c45eb6e563b40a1cbc6cae12867798c7c9
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Mail\Protocol\Smtp\Auth;
12 use Zend\Mail\Protocol\Smtp;
14 /**
15 * Performs LOGIN authentication
17 class Login extends Smtp
19 /**
20 * LOGIN username
22 * @var string
24 protected $username;
27 /**
28 * LOGIN password
30 * @var string
32 protected $password;
35 /**
36 * Constructor.
38 * @param string $host (Default: 127.0.0.1)
39 * @param int $port (Default: null)
40 * @param array $config Auth-specific parameters
42 public function __construct($host = '127.0.0.1', $port = null, $config = null)
44 // Did we receive a configuration array?
45 $origConfig = $config;
46 if (is_array($host)) {
47 // Merge config array with principal array, if provided
48 if (is_array($config)) {
49 $config = array_replace_recursive($host, $config);
50 } else {
51 $config = $host;
55 if (is_array($config)) {
56 if (isset($config['username'])) {
57 $this->setUsername($config['username']);
59 if (isset($config['password'])) {
60 $this->setPassword($config['password']);
64 // Call parent with original arguments
65 parent::__construct($host, $port, $origConfig);
69 /**
70 * Perform LOGIN authentication with supplied credentials
73 public function auth()
75 // Ensure AUTH has not already been initiated.
76 parent::auth();
78 $this->_send('AUTH LOGIN');
79 $this->_expect(334);
80 $this->_send(base64_encode($this->getUsername()));
81 $this->_expect(334);
82 $this->_send(base64_encode($this->getPassword()));
83 $this->_expect(235);
84 $this->auth = true;
87 /**
88 * Set value for username
90 * @param string $username
91 * @return Login
93 public function setUsername($username)
95 $this->username = $username;
96 return $this;
99 /**
100 * Get username
102 * @return string
104 public function getUsername()
106 return $this->username;
110 * Set value for password
112 * @param string $password
113 * @return Login
115 public function setPassword($password)
117 $this->password = $password;
118 return $this;
122 * Get password
124 * @return string
126 public function getPassword()
128 return $this->password;