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 AppSend 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
| Variable | Description |
|---|---|
EMAIL_PROVIDER | smtp, resend, unsent, postmark, sendgrid, brevo, mailgun, amazon_ses, 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 |
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) |
§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)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.
- Attachment
- An email attachment.
- Delivery
Result - Result of a successful email delivery.
- An email message.
Enums§
- Attachment
Type - Type of attachment disposition.
- Mail
Error - Errors that can occur when sending emails.
Constants§
- VERSION
- The version of the missive crate.
Traits§
- Mailer
- Trait for email delivery providers.
- Mailer
Ext - 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).