MailBreeze Rust SDK
Official Rust SDK for MailBreeze - Email Marketing & Transactional Email Platform.
Features
- 📧 Email Sending - Transactional and marketing emails
- 👥 Contact Management - Create, update, and organize contacts
- 📋 List Management - Mailing lists with statistics
- ✅ Email Verification - Single and batch verification
- 📎 Attachments - Upload and manage email attachments
- 🔄 Automatic Retries - Exponential backoff for transient errors
- 🔒 Secure - API key redacted from debug output
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick Start
use ;
async
Configuration
Use the builder pattern for custom configuration:
use MailBreeze;
use Duration;
let client = builder
.base_url
.timeout
.max_retries
.build?;
Resources
Emails
// Send an email
let result = client.emails.send.await?;
println!;
// Get email by ID
let email = client.emails.get.await?;
// List emails
let email_list = client.emails.list.await?;
for email in email_list.emails
// Get statistics
let stats = client.emails.stats.await?;
Contacts
Contacts are managed within a specific list:
// Get contacts resource for a list
let contacts = client.contacts;
// Create a contact
let contact = contacts.create.await?;
// Update a contact
let contact = contacts.update.await?;
// List contacts
let contact_list = contacts.list.await?;
for contact in contact_list.contacts
// Suppress a contact (prevent receiving emails)
contacts.suppress.await?;
// Delete a contact
contacts.delete.await?;
Lists
// Create a list
let list = client.lists.create.await?;
// List all lists
let all_lists = client.lists.list.await?;
for list in all_lists.lists
// Get a specific list
let list = client.lists.get.await?;
// Update a list
let list = client.lists.update.await?;
// Get list statistics
let stats = client.lists.stats.await?;
println!;
// Delete a list
client.lists.delete.await?;
Email Verification
// Verify single email
let result = client.verification.verify.await?;
if result.is_valid
// Batch verification (returns immediate results or verification_id for polling)
let batch = client.verification.batch.await?;
// Results are categorized as clean, dirty, or unknown
if let Some = batch.results
// Get verification status (for async batches with verification_id)
if !batch.verification_id.is_empty
// List all verification batches
let batches = client.verification.list.await?;
for batch in batches
// Get verification stats
let stats = client.verification.stats.await?;
println!;
Attachments
// Step 1: Create upload URL
let upload = client.attachments.create_upload_url.await?;
// Step 2: Upload file to the presigned URL (using reqwest or similar)
// reqwest::Client::new()
// .put(&upload.upload_url)
// .body(file_bytes)
// .header("Content-Type", "application/pdf")
// .send()
// .await?;
// Step 3: Confirm the upload
client.attachments.confirm.await?;
// Step 4: Use in email
let result = client.emails.send.await?;
// Get attachment details
let attachment = client.attachments.get.await?;
println!;
// Delete an attachment
client.attachments.delete.await?;
Error Handling
use ;
match client.emails.get.await
License
MIT License - see LICENSE for details.