ferrum_email/lib.rs
1//! # Ferrum Email
2//!
3//! **The complete email framework for Rust.** One crate, everything included.
4//!
5//! Ferrum Email is the Rust equivalent of React Email + Resend: type-safe,
6//! composable email templates with cross-client-compatible HTML rendering
7//! and a unified async sending API.
8//!
9//! ## Quick Start
10//!
11//! ```toml
12//! [dependencies]
13//! ferrum-email = "0.1"
14//! tokio = { version = "1", features = ["full"] }
15//! ```
16//!
17//! ```rust,no_run
18//! use ferrum_email::prelude::*;
19//!
20//! struct WelcomeEmail { name: String }
21//!
22//! impl Component for WelcomeEmail {
23//! fn subject(&self) -> Option<&str> { Some("Welcome!") }
24//!
25//! fn render(&self) -> Node {
26//! Html::new()
27//! .child(Body::new().child(
28//! Container::new().child(
29//! Section::new().padding(Spacing::all(Px(32)))
30//! .child_node(
31//! Heading::h1(&format!("Hello, {}!", self.name))
32//! .color(Color::hex("2D2A26"))
33//! .into_node())
34//! .child_node(
35//! Button::new("https://example.com", "Get Started")
36//! .background(Color::hex("C0582B"))
37//! .text_color(Color::white())
38//! .into_node())
39//! )))
40//! .into_node()
41//! }
42//! }
43//!
44//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
45//! // Send via the Ferrum Mail platform
46//! let provider = SmtpProvider::builder()
47//! .host("ferrum-mail.com")
48//! .port(587)
49//! .credentials("fm_your_api_key", "")
50//! .build()?;
51//!
52//! let sender = Sender::new(provider, "you@yourapp.com");
53//! sender.send(&WelcomeEmail { name: "World".into() }, "user@example.com").await?;
54//! # Ok(())
55//! # }
56//! ```
57//!
58//! ## Architecture
59//!
60//! ```text
61//! ferrum-email (this crate — umbrella SDK)
62//! ├── ferrum-email-core — Component trait, Node tree, Style system
63//! ├── ferrum-email-components — Html, Body, Button, Text, etc.
64//! ├── ferrum-email-render — HTML renderer, CSS inliner, plain text
65//! └── ferrum-email-send — Sender, SMTP provider, NexusShield
66//! ```
67//!
68//! ## Feature Flags
69//!
70//! | Feature | Default | Description |
71//! |---------|---------|-------------|
72//! | `smtp` | Yes | Native SMTP provider with STARTTLS |
73//! | `shield` | Yes | NexusShield email security validation |
74//! | `vault` | No | NexusVault encrypted credential storage |
75//!
76//! ## Sending via Ferrum Mail Platform
77//!
78//! Sign up at [ferrum-mail.com](https://ferrum-mail.com) for managed email delivery:
79//!
80//! ```rust,no_run
81//! # use ferrum_email::prelude::*;
82//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
83//! let provider = SmtpProvider::builder()
84//! .host("ferrum-mail.com")
85//! .port(587)
86//! .credentials("fm_your_api_key", "")
87//! .build()?;
88//! # Ok(())
89//! # }
90//! ```
91//!
92//! Or use your own SMTP server:
93//!
94//! ```rust,no_run
95//! # use ferrum_email::prelude::*;
96//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
97//! let provider = SmtpProvider::builder()
98//! .host("smtp.office365.com")
99//! .port(587)
100//! .credentials("user@example.com", "password")
101//! .build()?;
102//! # Ok(())
103//! # }
104//! ```
105
106// Re-export all sub-crates
107pub use ferrum_email_core as core;
108pub use ferrum_email_components as components;
109pub use ferrum_email_render as render;
110pub use ferrum_email_send as send;
111
112/// The prelude — import everything you need with one `use` statement.
113///
114/// ```rust
115/// use ferrum_email::prelude::*;
116/// ```
117pub mod prelude {
118 // Core types
119 pub use ferrum_email_core::{
120 Component, Node, Element, Tag, Attr, Style, Border, BorderStyle,
121 Color, Spacing, Px, Percent, SizeValue,
122 FontFamily, FontWeight, TextAlign, VerticalAlign,
123 LineHeight, Display, TextDecoration, HeadingLevel,
124 };
125
126 // All components
127 pub use ferrum_email_components::{
128 Html, Head, Body, Preview, Container, Section, Row, Column,
129 Text, Heading, Button, Link, Image, Hr, Code, CodeBlock, Spacer,
130 };
131
132 // Renderer
133 pub use ferrum_email_render::{Renderer, RenderConfig, RenderError};
134
135 // Sender and providers
136 pub use ferrum_email_send::{
137 Sender, EmailProvider, EmailMessage, EmailError,
138 Mailbox, Attachment, EmailTag, SendResult,
139 };
140
141 // SMTP provider
142 #[cfg(feature = "smtp")]
143 pub use ferrum_email_send::providers::SmtpProvider;
144
145 // Console provider (always available)
146 pub use ferrum_email_send::providers::ConsoleProvider;
147}