br-email
Rust email library supporting IMAP, POP3, and SMTP with TLS, incremental sync, connection reuse, and automatic retry.
Features
- IMAP - Receive emails via IMAP/TLS (port 993), UID-based incremental sync
- POP3 - Receive emails via POP3/TLS (port 995), UIDL-based incremental sync
- SMTP - Send emails via SMTP/STARTTLS (port 25/587), powered by
lettre - Email Parsing - MIME parsing, headers, attachments, encoded content
- Connection Reuse - Cached connections with automatic reconnect on failure
- Retry - Exponential backoff (3 retries, 2s/4s/8s delays)
- Thread Pool - Parallel operations via
poolsmodule
Usage
Receive (IMAP)
use ;
let mut mail = new;
let mut recv = mail.receive;
let total = recv.get_total?;
let email_data = recv.get_mail?;
Receive (POP3)
use ;
let mut mail = new;
let mut recv = mail.receive;
let total = recv.get_total?;
let email_data = recv.get_mail?;
Send (SMTP)
use ;
let mut mail = new;
let mut sender = mail.sender;
sender.set_from;
sender.set_to;
sender.set_subject;
sender.set_body;
sender.send?;
Incremental Sync (IMAP - UID)
let mut recv = mail.receive;
let validity = recv.get_validity?; // UIDVALIDITY - resync if changed
let max_uid = recv.get_max_uid?; // Highest UID
let new_uids = recv.get_new_since?; // UIDs > 100
Incremental Sync (POP3 - UIDL)
let mut recv = mail.receive;
let uidl_map = recv.get_uidl_map?; // Vec<(seq, uidl)>
// Compare with stored UIDLs to find new messages
Parse Email
use Mail;
let data: = /* raw email bytes */;
let parsed = analyze?;
// Access: parsed.subject, parsed.from, parsed.body, parsed.attachments, etc.
Config File
use ;
let config = create?;
let mut mail = new_new?;
Feature Flags
[]
= "1.2" # All features (imap + pop3 + smtp)
= { = "1.2", = false, = ["imap"] } # IMAP only
| Feature | Default | Description |
|---|---|---|
imap |
Yes | IMAP receive support |
pop3 |
Yes | POP3 receive support |
smtp |
Yes | SMTP send support (depends on lettre) |
License
MIT