|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* 00004 * This file is part of SwiftMailer. 00005 * (c) 2004-2009 Chris Corbyn 00006 * 00007 * For the full copyright and license information, please view the LICENSE 00008 * file that was distributed with this source code. 00009 */ 00010 00011 //@require 'Swift/Transport/Esmtp/Authenticator.php'; 00012 //@require 'Swift/Transport/SmtpAgent.php'; 00013 //@require 'Swift/TransportException.php'; 00014 00015 /** 00016 * Handles LOGIN authentication. 00017 * @package Swift 00018 * @subpackage Transport 00019 * @author Chris Corbyn 00020 */ 00021 class Swift_Transport_Esmtp_Auth_LoginAuthenticator 00022 implements Swift_Transport_Esmtp_Authenticator 00023 { 00024 00025 /** 00026 * Get the name of the AUTH mechanism this Authenticator handles. 00027 * @return string 00028 */ 00029 public function getAuthKeyword() 00030 { 00031 return 'LOGIN'; 00032 } 00033 00034 /** 00035 * Try to authenticate the user with $username and $password. 00036 * @param Swift_Transport_SmtpAgent $agent 00037 * @param string $username 00038 * @param string $password 00039 * @return boolean 00040 */ 00041 public function authenticate(Swift_Transport_SmtpAgent $agent, 00042 $username, $password) 00043 { 00044 try 00045 { 00046 $agent->executeCommand("AUTH LOGIN\r\n", array(334)); 00047 $agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), array(334)); 00048 $agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), array(235)); 00049 return true; 00050 } 00051 catch (Swift_TransportException $e) 00052 { 00053 $agent->executeCommand("RSET\r\n", array(250)); 00054 return false; 00055 } 00056 } 00057 00058 }
1.8.0