/** * Try to authenticate using the username and password * Returns false on failure * @param string The username * @param string The password * @param Swift The instance of Swift this authenticator is used in * @return boolean */ public function isAuthenticated($user, $pass, Swift $swift) { try { //The authorization string uses ascii null as a separator (See RFC 2554) $credentials = base64_encode($user . chr(0) . $user . chr(0) . $pass); $swift->command("AUTH PLAIN " . $credentials, 235); } catch (Swift_ConnectionException $e) { $swift->reset(); return false; } return true; }
/** * Try to authenticate using the username and password * Returns false on failure * @param string The username * @param string The password * @param Swift The instance of Swift this authenticator is used in * @return boolean */ public function isAuthenticated($user, $pass, Swift $swift) { try { $swift->command("AUTH LOGIN", 334); $swift->command(base64_encode($user), 334); $swift->command(base64_encode($pass), 235); } catch (Swift_ConnectionException $e) { $swift->reset(); return false; } return true; }
/** * Try to authenticate using the username and password * Returns false on failure * @param string The username * @param string The password * @param Swift The instance of Swift this authenticator is used in * @return boolean */ public function isAuthenticated($user, $pass, Swift $swift) { try { $encoded_challenge = substr($swift->command("AUTH CRAM-MD5", 334)->getString(), 4); $challenge = base64_decode($encoded_challenge); $response = base64_encode($user . " " . self::generateCRAMMD5Hash($pass, $challenge)); $swift->command($response, 235); } catch (Swift_ConnectionException $e) { $swift->reset(); return false; } return true; }