#[non_exhaustive]pub enum AuthMechanism {
Plain,
Login,
XOAuth2,
OAuthBearer,
ScramSha256,
}Expand description
SASL authentication mechanisms supported by this client.
Today the crate implements PLAIN (RFC 4616) and LOGIN (the
historical mechanism used by many submission servers). The enum is
non_exhaustive so that future additions (e.g. XOAUTH2,
SCRAM-SHA-256) do not require a major version bump.
PLAIN is preferred when both are advertised: it is one network
round-trip rather than two, and is an IETF-standard SASL mechanism.
LOGIN is retained for compatibility with older submission servers
that advertise only it.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Plain
SASL PLAIN (RFC 4616). Sends \0user\0pass base64-encoded as
the initial response, completing in a single round-trip.
Login
LOGIN. Sends username and password as separate base64 lines
in response to two 334 server prompts.
XOAuth2
SASL XOAUTH2 (Google / Microsoft OAuth 2.0 SMTP extension).
Sends user={user}\x01auth=Bearer {token}\x01\x01
base64-encoded as the initial response. The “credential” passed
to login_with for this mechanism is an OAuth 2.0 access
token, not a static password — auto-selection by login()
deliberately does NOT pick this mechanism for that reason.
OAuthBearer
SASL OAUTHBEARER (RFC 7628). The IETF-standard OAuth 2.0 SASL
mechanism. Sends n,a={user},\x01auth=Bearer {token}\x01\x01
(GS2 header + Bearer token) base64-encoded as the initial
response. More interoperable than XOAUTH2 and defined by an
IETF RFC. Like XOAUTH2, auto-selection by login() does NOT
pick this mechanism because the credential is a token, not a
password.
Available only with the oauthbearer cargo feature (default-on).
ScramSha256
SASL SCRAM-SHA-256 (RFC 5802 / RFC 7677). Challenge-response
authentication: the client never transmits the password, and
the server proves possession of the salted hash through a
signature step. Auto-selection by login() prefers this
mechanism over PLAIN and LOGIN when the server advertises
it.
Available only with the scram-sha-256 cargo feature
(default-on).
Implementations§
Trait Implementations§
Source§impl Clone for AuthMechanism
impl Clone for AuthMechanism
Source§fn clone(&self) -> AuthMechanism
fn clone(&self) -> AuthMechanism
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuthMechanism
impl Debug for AuthMechanism
Source§impl Display for AuthMechanism
impl Display for AuthMechanism
Source§impl Hash for AuthMechanism
impl Hash for AuthMechanism
Source§impl PartialEq for AuthMechanism
impl PartialEq for AuthMechanism
Source§fn eq(&self, other: &AuthMechanism) -> bool
fn eq(&self, other: &AuthMechanism) -> bool
self and other values to be equal, and is used by ==.