|
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 PLAIN authentication. 00017 * @package Swift 00018 * @subpackage Transport 00019 * @author Chris Corbyn 00020 */ 00021 class Swift_Transport_Esmtp_Auth_PlainAuthenticator 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 'PLAIN'; 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 $message = base64_encode($username . chr(0) . $username . chr(0) . $password); 00047 $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235)); 00048 return true; 00049 } 00050 catch (Swift_TransportException $e) 00051 { 00052 $agent->executeCommand("RSET\r\n", array(250)); 00053 return false; 00054 } 00055 } 00056 00057 }
1.8.0