/**
* Try to authenticate the user with $email and $token.
*
* @param Swift_Transport_SmtpAgent $agent
* @param string $email
* @param string $token
*
* @return bool
*/
public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token)
{
try {
$param = $this->constructXOAuth2Params($email, $token);
$agent->executeCommand("AUTH XOAUTH2 " . $param . "\r\n", array(235));
return true;
} catch (Swift_TransportException $e) {
$agent->executeCommand("RSET\r\n", array(250));
return false;
}
}