#[non_exhaustive]pub struct MailConfig {
pub mailer: MailDriver,
pub host: String,
pub port: Option<u16>,
pub username: Option<String>,
pub password: Option<String>,
pub encryption: MailEncryption,
pub from_address: String,
pub from_name: Option<String>,
pub timeout: Duration,
pub failover: Vec<String>,
}Expand description
Mail settings, from MAIL_*.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.mailer: MailDriverHow mail is sent: SMTP, the log or memory.
host: StringSMTP server, from MAIL_HOST (default localhost).
port: Option<u16>SMTP port, from MAIL_PORT; None uses the encryption’s usual port.
username: Option<String>SMTP user name, from MAIL_USERNAME.
password: Option<String>SMTP password, from MAIL_PASSWORD.
encryption: MailEncryptiontls (usually port 465), starttls (587) or none (e.g. Mailpit on 1025).
from_address: StringSender address, from MAIL_FROM_ADDRESS (default hello@example.com).
from_name: Option<String>Sender name, from MAIL_FROM_NAME.
timeout: DurationHow long sending one mail over SMTP may take, from MAIL_TIMEOUT in
seconds (default 10).
failover: Vec<String>Mailers (App::mailer names) to try in order when this one fails,
from MAIL_FAILOVER (comma-separated), e.g. backup for a second
SMTP provider.
Implementations§
Source§impl MailConfig
impl MailConfig
Sourcepub fn from_env(config: &Config, prefix: &str) -> Result<Self>
pub fn from_env(config: &Config, prefix: &str) -> Result<Self>
A mailer’s settings from variables starting with prefix, for
App::mailer: <PREFIX>_MAILER (smtp,
log or memory; default: the app’s MAIL_MAILER, so it logs
while developing and keeps mail in memory in tests), <PREFIX>_HOST, _PORT,
_USERNAME, _PASSWORD, _ENCRYPTION, _TIMEOUT (seconds), and
<PREFIX>_FROM_ADDRESS / _FROM_NAME, which fall back to the
app’s MAIL_FROM_*. A value that doesn’t fit (an unknown driver, a
port that isn’t a number) is an error naming the variable, and the
app doesn’t boot.
Trait Implementations§
Source§impl Clone for MailConfig
impl Clone for MailConfig
Source§impl Debug for MailConfig
impl Debug for MailConfig
Auto Trait Implementations§
impl Freeze for MailConfig
impl RefUnwindSafe for MailConfig
impl Send for MailConfig
impl Sync for MailConfig
impl Unpin for MailConfig
impl UnsafeUnpin for MailConfig
impl UnwindSafe for MailConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more