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 / Plain.php
blob97d028dc873786529cb1d2629f292d3de1826e9a
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 PLAIN authentication
17 class Plain extends Smtp
19 /**
20 * PLAIN username
22 * @var string
24 protected $username;
27 /**
28 * PLAIN 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 PLAIN authentication with supplied credentials
73 public function auth()
75 // Ensure AUTH has not already been initiated.
76 parent::auth();
78 $this->_send('AUTH PLAIN');
79 $this->_expect(334);
80 $this->_send(base64_encode("\0" . $this->getUsername() . "\0" . $this->getPassword()));
81 $this->_expect(235);
82 $this->auth = true;
85 /**
86 * Set value for username
88 * @param string $username
89 * @return Plain
91 public function setUsername($username)
93 $this->username = $username;
94 return $this;
97 /**
98 * Get username
100 * @return string
102 public function getUsername()
104 return $this->username;
108 * Set value for password
110 * @param string $password
111 * @return Plain
113 public function setPassword($password)
115 $this->password = $password;
116 return $this;
120 * Get password
122 * @return string
124 public function getPassword()
126 return $this->password;