Skip to main content

Crate ferrum_email

Crate ferrum_email 

Source
Expand description

§Ferrum Email

The complete email framework for Rust. One crate, everything included.

Ferrum Email is the Rust equivalent of React Email + Resend: type-safe, composable email templates with cross-client-compatible HTML rendering and a unified async sending API.

§Quick Start

[dependencies]
ferrum-email = "0.1"
tokio = { version = "1", features = ["full"] }
use ferrum_email::prelude::*;

struct WelcomeEmail { name: String }

impl Component for WelcomeEmail {
    fn subject(&self) -> Option<&str> { Some("Welcome!") }

    fn render(&self) -> Node {
        Html::new()
            .child(Body::new().child(
                Container::new().child(
                    Section::new().padding(Spacing::all(Px(32)))
                        .child_node(
                            Heading::h1(&format!("Hello, {}!", self.name))
                                .color(Color::hex("2D2A26"))
                                .into_node())
                        .child_node(
                            Button::new("https://example.com", "Get Started")
                                .background(Color::hex("C0582B"))
                                .text_color(Color::white())
                                .into_node())
                )))
            .into_node()
    }
}

// Send via the Ferrum Mail platform
let provider = SmtpProvider::builder()
    .host("ferrum-mail.com")
    .port(587)
    .credentials("fm_your_api_key", "")
    .build()?;

let sender = Sender::new(provider, "you@yourapp.com");
sender.send(&WelcomeEmail { name: "World".into() }, "user@example.com").await?;

§Architecture

ferrum-email (this crate — umbrella SDK)
 ├── ferrum-email-core        — Component trait, Node tree, Style system
 ├── ferrum-email-components  — Html, Body, Button, Text, etc.
 ├── ferrum-email-render      — HTML renderer, CSS inliner, plain text
 └── ferrum-email-send        — Sender, SMTP provider, NexusShield

§Feature Flags

FeatureDefaultDescription
smtpYesNative SMTP provider with STARTTLS
shieldYesNexusShield email security validation
vaultNoNexusVault encrypted credential storage

§Sending via Ferrum Mail Platform

Sign up at ferrum-mail.com for managed email delivery:

let provider = SmtpProvider::builder()
    .host("ferrum-mail.com")
    .port(587)
    .credentials("fm_your_api_key", "")
    .build()?;

Or use your own SMTP server:

let provider = SmtpProvider::builder()
    .host("smtp.office365.com")
    .port(587)
    .credentials("user@example.com", "password")
    .build()?;

Re-exports§

pub use ferrum_email_core as core;
pub use ferrum_email_components as components;
pub use ferrum_email_render as render;
pub use ferrum_email_send as send;

Modules§

prelude
The prelude — import everything you need with one use statement.