async-mailer
An async dyn Mailer trait with runtime-pluggable Outlook (Office365) and SMTP implementations.
Example:
// Outlook configuration, e.g. from command line arguments or environment variables.
let mailer_configuration = Outlook ;
// Alternative: SMTP configuration, e.g. from command line arguments or environment variables.
let mailer_configuration = Outlook ;
// Create a `Box<dyn Mailer>`.
// The implementation is `Send` and `Sync` and may be store e.g. as part of your server state.
let mailer = new_mailer.await?;
// 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 = new
.from
.to
.subject
.text_body;
// Send the message using the implementation-agnostic `dyn Mailer`.
mailer.send_mail.await?;
Roadmap
DKIM support is planned to be implemented on the SmtpMailer.
Further mailer implementations are possible. Please open an issue and ideally provide a pull request to add your alternative mailer implementation!