Skip to main content

AuthMechanism

Enum AuthMechanism 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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§

Source§

impl AuthMechanism

Source

pub const fn name(self) -> &'static str

SMTP-on-the-wire keyword for this mechanism.

Trait Implementations§

Source§

impl Clone for AuthMechanism

Source§

fn clone(&self) -> AuthMechanism

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuthMechanism

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for AuthMechanism

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for AuthMechanism

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for AuthMechanism

Source§

fn eq(&self, other: &AuthMechanism) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for AuthMechanism

Source§

impl Eq for AuthMechanism

Source§

impl StructuralPartialEq for AuthMechanism

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.