XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
PlainAuthenticator.php
Go to the documentation of this file.
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 
23 {
24 
29  public function getAuthKeyword()
30  {
31  return 'PLAIN';
32  }
33 
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 }