TYPO3  7.6
XOAuth2Authenticator.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 
27 {
33  public function getAuthKeyword()
34  {
35  return 'XOAUTH2';
36  }
37 
47  public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token)
48  {
49  try {
50  $param = $this->constructXOAuth2Params($email, $token);
51  $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", array(235));
52 
53  return true;
54  } catch (Swift_TransportException $e) {
55  $agent->executeCommand("RSET\r\n", array(250));
56 
57  return false;
58  }
59  }
60 
66  protected function constructXOAuth2Params($email, $token)
67  {
68  return base64_encode("user=$email\1auth=Bearer $token\1\1");
69  }
70 }