PageRenderTime 53ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/tine20/library/Zend/Mail/Protocol/Smtp/Auth/Plain.php

https://gitlab.com/rsilveira1987/Expresso
PHP | 96 lines | 28 code | 12 blank | 56 comment | 3 complexity | 6109dbe3ab2fcb72b3a219bea144821a MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Mail
  17. * @subpackage Protocol
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Plain.php 10020 2009-08-18 14:34:09Z j.fischer@metaways.de $
  21. */
  22. /**
  23. * @see Zend_Mail_Protocol_Smtp
  24. */
  25. require_once 'Zend/Mail/Protocol/Smtp.php';
  26. /**
  27. * Performs PLAIN authentication
  28. *
  29. * @category Zend
  30. * @package Zend_Mail
  31. * @subpackage Protocol
  32. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Mail_Protocol_Smtp_Auth_Plain extends Zend_Mail_Protocol_Smtp
  36. {
  37. /**
  38. * PLAIN username
  39. *
  40. * @var string
  41. */
  42. protected $_username;
  43. /**
  44. * PLAIN password
  45. *
  46. * @var string
  47. */
  48. protected $_password;
  49. /**
  50. * Constructor.
  51. *
  52. * @param string $host (Default: 127.0.0.1)
  53. * @param int $port (Default: null)
  54. * @param array $config Auth-specific parameters
  55. * @return void
  56. */
  57. public function __construct($host = '127.0.0.1', $port = null, $config = null)
  58. {
  59. if (is_array($config)) {
  60. if (isset($config['username'])) {
  61. $this->_username = $config['username'];
  62. }
  63. if (isset($config['password'])) {
  64. $this->_password = $config['password'];
  65. }
  66. }
  67. parent::__construct($host, $port, $config);
  68. }
  69. /**
  70. * Perform PLAIN authentication with supplied credentials
  71. *
  72. * @return void
  73. */
  74. public function auth()
  75. {
  76. // Ensure AUTH has not already been initiated.
  77. parent::auth();
  78. $this->_send('AUTH PLAIN');
  79. $this->_expect(334);
  80. $this->_send(base64_encode(chr(0) . $this->_username . chr(0) . $this->_password));
  81. $this->_expect(235);
  82. $this->_auth = true;
  83. }
  84. }