Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of SwiftMailer.
5
 * (c) 2004-2009 Chris Corbyn
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
//@require 'Swift/Transport/Esmtp/Authenticator.php';
12
//@require 'Swift/Transport/SmtpAgent.php';
13
//@require 'Swift/TransportException.php';
14
 
15
/**
16
 * Handles LOGIN authentication.
17
 * @package Swift
18
 * @subpackage Transport
19
 * @author Chris Corbyn
20
 */
21
class Swift_Transport_Esmtp_Auth_LoginAuthenticator
22
  implements Swift_Transport_Esmtp_Authenticator
23
{
24
 
25
  /**
26
   * Get the name of the AUTH mechanism this Authenticator handles.
27
   * @return string
28
   */
29
  public function getAuthKeyword()
30
  {
31
    return 'LOGIN';
32
  }
33
 
34
  /**
35
   * Try to authenticate the user with $username and $password.
36
   * @param Swift_Transport_SmtpAgent $agent
37
   * @param string $username
38
   * @param string $password
39
   * @return boolean
40
   */
41
  public function authenticate(Swift_Transport_SmtpAgent $agent,
42
    $username, $password)
43
  {
44
    try
45
    {
46
      $agent->executeCommand("AUTH LOGIN\r\n", array(334));
47
      $agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), array(334));
48
      $agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), array(235));
49
      return true;
50
    }
51
    catch (Swift_TransportException $e)
52
    {
53
      $agent->executeCommand("RSET\r\n", array(250));
54
      return false;
55
    }
56
  }
57
 
58
}