Crate armature_mail

Crate armature_mail 

Source
Expand description

§Armature Mail

Email sending with SMTP, templates, and cloud provider integrations.

§Features

  • SMTP Transport: Direct SMTP email sending with TLS support
  • Email Templates: HTML and text templates with Handlebars, Tera, or MiniJinja
  • Cloud Providers: SendGrid, Mailgun, AWS SES integrations
  • Attachments: File and inline attachments
  • Async Queue: Non-blocking email sending with retries

§Quick Start

use armature_mail::{Mailer, SmtpConfig, Email};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Configure SMTP
    let config = SmtpConfig::new("smtp.example.com")
        .credentials("user@example.com", "password")
        .port(587)
        .starttls();

    let mailer = Mailer::smtp(config).await?;

    // Send an email
    let email = Email::new()
        .from("sender@example.com")
        .to("recipient@example.com")
        .subject("Hello from Armature!")
        .text("This is a test email.")
        .html("<h1>Hello!</h1><p>This is a test email.</p>");

    mailer.send(email).await?;
    Ok(())
}

§With Templates

use armature_mail::{Mailer, SmtpConfig, TemplateEngine};
use serde_json::json;

let mailer = Mailer::smtp(config).await?
    .with_templates("./templates")?;

// Send using a template
mailer.send_template(
    "welcome",
    "user@example.com",
    json!({
        "name": "John",
        "activation_link": "https://example.com/activate/abc123"
    }),
).await?;

Modules§

prelude
Prelude for common imports.

Structs§

Address
Email address with optional display name.
Attachment
Email attachment.
Email
Email message.
EmailBuilder
Email builder with validation.
HandlebarsEngine
Handlebars-based template engine for emails.
Mailbox
A mailbox is an address with a required display name.
Mailer
High-level mailer for sending emails.
MailerConfig
Mailer configuration.
RenderedTemplate
Rendered template output.
SmtpConfig
SMTP configuration.
SmtpTransport
SMTP transport.

Enums§

ContentDisposition
Content disposition for attachments.
MailError
Mail errors.
SmtpSecurity
SMTP security mode.

Traits§

IntoAddress
Trait for types that can be converted to an Address.
TemplateEngine
Template engine trait for rendering email templates.
Transport
Email transport trait.

Type Aliases§

Result
Result type for mail operations.