rustlavel-mail 0.2.0

Rustlavel mail: MIME messages, an SMTP client written on Tokio, and multi-channel notifications
Documentation

rustlavel-mail: sending email, and notifications that fan out to several channels from one definition.

The SMTP client is written here, on Tokio's TCP, the same way the HTTP server and the PostgreSQL driver are — only TLS is delegated, to rustls.

use rustlavel_mail::{Mail, Message};

let mailer = Mail::from_config(&config)?;
mailer.send(
    Message::new()
        .to(("Ada Lovelace", "ada@example.com"))
        .subject("Your receipt")
        .html("<p>Thank you.</p>"),
).await?;

The three transports

mail.transport picks one, and nothing else in an application changes:

  • log — writes the rendered message to the log. The local default: mail you can read without a mail server, an inbox, or a network.
  • file — one .eml per message under mail.path, which any mail client will open, so a designer can look at the real thing.
  • smtp — the real one.

Testing

[Mail::fake] records what would have been sent and sends nothing, so a test can assert on the subject and the body without a server anywhere:

let mailer = Mail::fake();
ship_the_order(&mailer).await?;
mailer.fake().unwrap().assert_sent_to("ada@example.com");