Expand description
§Missive
Compose, deliver, and test emails in Rust. Plug and play.
§Quick Start
Create a client and pass it through your application state:
ⓘ
use missive::{Email, EmailClient};
use missive::providers::ResendMailer;
let mailer = ResendMailer::new(std::env::var("RESEND_API_KEY")?);
let client = EmailClient::new(mailer)
.with_default_from("noreply@example.com");
let email = Email::new()
.to("user@example.com")
.subject("Welcome!")
.text_body("Hello");
client.deliver(email).await?;The legacy deliver(&email) global facade remains available for small apps
and compatibility, but EmailClient is the primary API.
For explicit environment loading, use EmailClient::from_env().
§Multiple Clients
ⓘ
use missive::{Email, EmailClient};
use missive::providers::ResendMailer;
let transactional = EmailClient::new(ResendMailer::new("transactional_key"))
.with_default_from("receipts@example.com");
let marketing = EmailClient::new(ResendMailer::new("marketing_key"))
.with_default_from("news@example.com");
transactional.deliver(receipt_email).await?;
marketing.deliver(newsletter_email).await?;§Environment Variables
| Variable | Description |
|---|---|
EMAIL_PROVIDER | smtp, resend, unsent, postmark, sendgrid, brevo, mailgun, amazon_ses, mailtrap, mailjet, socketlabs, gmail, protonbridge, jmap, logger, logger_full |
EMAIL_FROM | Default sender email |
EMAIL_FROM_NAME | Default sender name |
SMTP_HOST | SMTP server host |
SMTP_PORT | SMTP server port (default: 587) |
SMTP_USERNAME | SMTP username |
SMTP_PASSWORD | SMTP password |
SMTP_TLS | SMTP TLS mode: starttls (default), tls, or none |
RESEND_API_KEY | Resend API key |
UNSENT_API_KEY | Unsent API key |
POSTMARK_API_KEY | Postmark API key |
SENDGRID_API_KEY | SendGrid API key |
BREVO_API_KEY | Brevo API key |
MAILGUN_API_KEY | Mailgun API key |
MAILGUN_DOMAIN | Mailgun sending domain |
AWS_REGION | AWS region for SES |
AWS_ACCESS_KEY_ID | AWS access key |
AWS_SECRET_ACCESS_KEY | AWS secret key |
MAILTRAP_API_KEY | Mailtrap API key |
MAILTRAP_SANDBOX_INBOX_ID | Mailtrap sandbox inbox ID (optional) |
MAILJET_API_KEY | Mailjet API key |
MAILJET_SECRET_KEY | Mailjet secret key |
SOCKETLABS_SERVER_ID | SocketLabs server ID |
SOCKETLABS_API_KEY | SocketLabs API key |
GMAIL_ACCESS_TOKEN | Gmail OAuth2 access token |
PROTONBRIDGE_USERNAME | Proton Bridge SMTP username |
PROTONBRIDGE_PASSWORD | Proton Bridge SMTP password |
PROTONBRIDGE_HOST | Proton Bridge host (default: 127.0.0.1) |
PROTONBRIDGE_PORT | Proton Bridge port (default: 1025) |
JMAP_URL | JMAP server URL |
JMAP_USERNAME | JMAP username (for basic auth) |
JMAP_PASSWORD | JMAP password (for basic auth) |
JMAP_BEARER_TOKEN | JMAP bearer token (for OAuth2) |
§Feature Flags
smtp- SMTP provider via lettreresend- Resend API providerunsent- Unsent API providerpostmark- Postmark API providersendgrid- SendGrid API providerbrevo- Brevo API provider (formerly Sendinblue)mailgun- Mailgun API provideramazon_ses- Amazon SES API providermailtrap- Mailtrap API provider (testing/staging)mailjet- Mailjet API providersocketlabs- SocketLabs Injection API providergmail- Gmail API provider (OAuth2)protonbridge- Proton Bridge provider (local SMTP)jmap- JMAP protocol provider (Stalwart, Fastmail, etc.)local- LocalMailer for development and testingpreview- Mailbox preview web UImetrics- Prometheus-style metrics (counters/histograms)dev- Enables local and preview
§Metrics
Enable features = ["metrics"] to emit Prometheus-style metrics:
| Metric | Type | Labels | Description |
|---|---|---|---|
missive_emails_total | Counter | provider, status | Total emails sent |
missive_delivery_duration_seconds | Histogram | provider | Delivery duration |
missive_batch_total | Counter | provider, status | Total batch operations |
missive_batch_size | Histogram | provider | Emails 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.
- ApiKey
Config - Configuration for providers that require one API key.
- Attachment
- An email attachment.
- Delivery
Result - Result of a successful email delivery.
- An email message.
- Email
Client - Instance-owned email client.
- Prepared
Email - An email that has passed Missive’s shared delivery validation.
Enums§
- Attachment
Type - Type of attachment disposition.
- Mail
Error - Errors that can occur when sending emails.
- Mailer
Config - Typed configuration for building a mailer from environment-like input.
Constants§
- VERSION
- The version of the missive crate.
Traits§
- Mailer
- Trait for email delivery providers.
- 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).