Crate async_mailer

source ·
Expand description

Create a dynamic mailer trait object depending on runtime mailer configuration.

Microsoft Outlook and SMTP mailer variants are available.

Example:

// Create a `BoxMailer`.
//
// Alternative implementations can be used.

let mailer = OutlookMailer::new(
    "<Microsoft Identity service tenant>",
    "<OAuth2 app GUID>",
    "<OAuth2 app secret>"
).await?;

// Alternative:
let mailer = SmtpMailer::new(
    "smtp.example.com",
    465,
    SmtpInvalidCertsPolicy::Deny,
    "<username>",
    "<password>"
);

// The implementation is `Send` and `Sync` and may be stored e.g. as part of your server state.

// Build a message using the re-exported `mail_builder::MessageBuilder'.
// For blazingly fast rendering of beautiful HTML mail, I recommend combining `askama` with `mrml`.
let message = MessageBuilder::new()
    .from(("From Name", "from@example.com"))
    .to("to@example.com")
    .subject("Subject")
    .text_body("Mail body");

// Send the message using the implementation-agnostic `dyn DynMailer`.
mailer.send_mail(&message).await?;

Re-exports

  • pub use async_mailer_core::mail_send;
  • pub use async_mailer_core::mail_send::mail_builder;

Structs

  • Builds an RFC5322 compliant MIME email message.
  • An Outlook mailer client, implementing the async_mailer::Mailer and async_mailer::DynMailer traits to be used as generic mailer or runtime-pluggable trait object.
  • Wrapper type for values that contains secrets, which attempts to limit accidental exposure and ensure secrets are wiped from memory when dropped. (e.g. passwords, cryptographic keys, access tokens or other credentials)
  • An SMTP mailer client, implementing the [async_mailer::Mailer] and [async_mailer::DynMailer] traits to be used as generic mailer or runtime-pluggable trait object.

Enums

Traits

Type Definitions