Crate missive

Crate missive 

Source
Expand description

§Missive

Compose, deliver, and test emails in Rust. Plug and play.

§Quick Start

Set environment variables:

EMAIL_PROVIDER=resend
RESEND_API_KEY=re_xxxxx
EMAIL_FROM=noreply@example.com
EMAIL_FROM_NAME=My App

Send emails from anywhere:

use missive::{Email, deliver};

let email = Email::new()
    .to("user@example.com")
    .subject("Welcome!")
    .text_body("Hello");

deliver(&email).await?;

That’s it. No configuration code needed.

§Per-Call Mailer Override

use missive::{Email, deliver_with};
use missive::providers::ResendMailer;

let mailer = ResendMailer::new("different_api_key");
deliver_with(&email, &mailer).await?;

§Environment Variables

VariableDescription
EMAIL_PROVIDERsmtp, resend, unsent, postmark, sendgrid, brevo, mailgun, amazon_ses, logger, logger_full
EMAIL_FROMDefault sender email
EMAIL_FROM_NAMEDefault sender name
SMTP_HOSTSMTP server host
SMTP_PORTSMTP server port (default: 587)
SMTP_USERNAMESMTP username
SMTP_PASSWORDSMTP password
RESEND_API_KEYResend API key
UNSENT_API_KEYUnsent API key
POSTMARK_API_KEYPostmark API key
SENDGRID_API_KEYSendGrid API key
BREVO_API_KEYBrevo API key
MAILGUN_API_KEYMailgun API key
MAILGUN_DOMAINMailgun sending domain
AWS_REGIONAWS region for SES
AWS_ACCESS_KEY_IDAWS access key
AWS_SECRET_ACCESS_KEYAWS secret key
MAILTRAP_API_KEYMailtrap API key
MAILTRAP_SANDBOX_INBOX_IDMailtrap sandbox inbox ID (optional)

§Feature Flags

  • smtp - SMTP provider via lettre
  • resend - Resend API provider
  • unsent - Unsent API provider
  • postmark - Postmark API provider
  • sendgrid - SendGrid API provider
  • brevo - Brevo API provider (formerly Sendinblue)
  • mailgun - Mailgun API provider
  • amazon_ses - Amazon SES API provider
  • mailtrap - Mailtrap API provider (testing/staging)
  • local - LocalMailer for development and testing
  • preview - Mailbox preview web UI
  • metrics - Prometheus-style metrics (counters/histograms)
  • dev - Enables local and preview

§Metrics

Enable features = ["metrics"] to emit Prometheus-style metrics:

MetricTypeLabelsDescription
missive_emails_totalCounterprovider, statusTotal emails sent
missive_delivery_duration_secondsHistogramproviderDelivery duration
missive_batch_totalCounterprovider, statusTotal batch operations
missive_batch_sizeHistogramproviderEmails per batch

Install a recorder (e.g., metrics-exporter-prometheus) in your app to collect them.

Re-exports§

pub use interceptor::Interceptor;
pub use interceptor::InterceptorExt;
pub use interceptor::WithInterceptor;

Modules§

interceptor
Email interceptors for modifying or blocking emails before delivery.
prelude
Prelude module for convenient imports.
providers
Email provider implementations.

Structs§

Address
An email address with an optional display name.
Attachment
An email attachment.
DeliveryResult
Result of a successful email delivery.
Email
An email message.

Enums§

AttachmentType
Type of attachment disposition.
MailError
Errors that can occur when sending emails.

Constants§

VERSION
The version of the missive crate.

Traits§

Mailer
Trait for email delivery providers.
MailerExt
Extension trait for optional mailer operations.
ToAddress
Trait for types that can be converted to an email address.

Functions§

configure
Manually configure the global mailer.
configure_arc
Configure with an Arc’d mailer.
default_from
Get the default from address from environment.
deliver
Deliver an email using the global mailer.
deliver_many
Deliver multiple emails using the global mailer.
deliver_with
Deliver an email using a specific mailer (per-call override).
init
Initialize the mailer from environment variables.
is_configured
Check if email is configured (env vars are set and feature is enabled).
mailer
Get a reference to the configured mailer (if initialized).
reset
Reset the global mailer (useful for tests).