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 PLAIN authentication.
17
 * @package Swift
18
 * @subpackage Transport
19
 * @author Chris Corbyn
20
 */
21
class Swift_Transport_Esmtp_Auth_PlainAuthenticator
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 'PLAIN';
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
      $message = base64_encode($username . chr(0) . $username . chr(0) . $password);
47
      $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235));
48
      return true;
49
    }
50
    catch (Swift_TransportException $e)
51
    {
52
      $agent->executeCommand("RSET\r\n", array(250));
53
      return false;
54
    }
55
  }
56
 
57
}