XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
LoginAuthenticator.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 'LOGIN';
32  }
33 
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 }