| Crates.io | sendemail |
| lib.rs | sendemail |
| version | 0.1.0 |
| created_at | 2025-11-10 03:03:09.481568+00 |
| updated_at | 2025-11-10 03:03:09.481568+00 |
| description | A Rust CLI tool for sending templated HTML emails via SMTP with batch processing, mail merge, and multi-profile support. |
| homepage | |
| repository | https://github.com/alejo-c/sendemail |
| max_upload_size | |
| id | 1924681 |
| size | 116,569 |
A Rust CLI application for sending templated HTML emails via SMTP with support for batch processing, mail merge, and attachments.
cargo build --release
Email account profiles are configured in config.toml at the project root:
[accounts.personal]
smtp_server = "smtp.gmail.com"
smtp_port = 587
sender_email = "your.email@gmail.com"
sender_name = "Your Name"
password = "your-app-password"
[accounts.work]
smtp_server = "smtp.office365.com"
smtp_port = 587
sender_email = "work@company.com"
sender_name = "Work Account"
Note: If password is omitted, you'll be prompted at runtime.
cargo run -- profiles
Send emails to individual or multiple recipients.
Basic Usage:
cargo run -- send --profile <profile> --recipients <email> --subject "..." [OPTIONS]
Options:
--profile <name> - Email account profile to use--recipients <emails>... - TO recipients--cc-recipients <emails>... - CC recipients--bcc-recipients <emails>... - BCC recipients--subject <text> - Email subject--body <text> - Plain text message (alternative to --template)--template <path> - Path to HTML template file--attachments <files>... - File attachments--data <json> - JSON data for template variablesExamples:
# Simple plain text email
cargo run -- send --profile personal \
--recipients user@example.com \
--subject "Test Email" \
--body "Hello World"
# Email with HTML template and data
cargo run -- send --profile personal \
--recipients user@example.com \
--subject "Welcome!" \
--template ./templates/register.html \
--data '{"name":"John Doe","link":"https://example.com/activate"}'
# Email with attachments
cargo run -- send --profile work \
--recipients user@example.com \
--subject "Your Certificate" \
--template ./templates/certificate.html \
--attachments ./cert.pdf
# Multiple recipients with CC and BCC
cargo run -- send --profile work \
--recipients user@example.com \
--cc-recipients manager@example.com supervisor@example.com \
--bcc-recipients admin@example.com \
--subject "Update" \
--body "System update notification"
Send the same email to a list of recipients from a CSV file with rate limiting.
Basic Usage:
cargo run -- batch --profile <profile> --recipients <csv_file> --subject "..." [OPTIONS]
Options:
--profile <name> - Email account profile to use--recipients <csv_file> - Path to CSV file with recipient list--subject <text> - Email subject--body <text> - Plain text message (alternative to --template)--template <path> - Path to HTML template file--attachments <files>... - File attachments (same for all recipients)--batch-size <num> - Recipients per batch (default: 25)--delay-minutes <num> - Minutes to wait between batches (default: 5)--limit <num> - Daily email limit (default: 1000)CSV Format:
email
user1@example.com
user2@example.com
user3@example.com
Or with recipient types:
email,type
user1@example.com,to
manager@example.com,cc
admin@example.com,bcc
Examples:
# Basic batch send
cargo run -- batch --profile work \
--recipients emails/list.csv \
--subject "Newsletter" \
--template ./templates/newsletter.html
# Batch with attachments and custom settings
cargo run -- batch --profile work \
--recipients emails/list.csv \
--subject "Your Certificate" \
--template ./templates/certificate.html \
--attachments ./cert.pdf \
--batch-size 50 \
--delay-minutes 3 \
--limit 500
# Test batch with limit
cargo run -- batch --profile personal \
--recipients emails/test.csv \
--subject "Test" \
--template ./templates/test.html \
--limit 5
Progress Tracking:
.progress file to track progress<csv_file>.progressSend personalized emails using CSV data with per-recipient template variables.
Basic Usage:
cargo run -- merge --profile <profile> --data <csv_file> --subject "..." --template <path> [OPTIONS]
Options:
--profile <name> - Email account profile to use--data <csv_file> - Path to CSV file with recipient data--subject <text> - Email subject--template <path> - Path to HTML template file (required)--delay-seconds <num> - Seconds to wait between emails (default: 1)--limit <num> - Maximum emails to send (default: 1000)CSV Format:
The CSV must have an email column. All other columns become template variables.
email,name,event,date
user1@example.com,John Doe,AI Workshop,June 10 2025
user2@example.com,Jane Smith,AI Workshop,June 10 2025
Special Columns:
email - Recipient email address (required)type - Recipient type: to, cc, or bcc (optional, default: to)attachment or attachments - File paths, semicolon-separated for multiple files (optional)CSV with Attachments:
email,name,event,attachments
user1@example.com,John Doe,Workshop 1,cert1.pdf
user2@example.com,Jane Smith,Workshop 2,cert2.pdf;badge2.jpg
user3@example.com,Bob Johnson,Workshop 3,cert3.pdf;badge3.jpg;photo3.png
Template Variables:
All CSV columns (except email, type, attachment, attachments) are available in templates:
<h1>Hello {{name}}!</h1>
<p>Thank you for attending {{event}} on {{date}}.</p>
<p>Your score: {{score}}</p>
Examples:
# Basic mail merge
cargo run -- merge --profile work \
--data participants.csv \
--subject "Your Certificate" \
--template ./templates/certificate.html
# Mail merge with per-recipient attachments
cargo run -- merge --profile work \
--data participants.csv \
--subject "Your Certificate" \
--template ./templates/certificate.html
# Mail merge with custom delay and limit
cargo run -- merge --profile personal \
--data users.csv \
--subject "Personal Update" \
--template ./templates/update.html \
--delay-seconds 2 \
--limit 100
Templates use Handlebars syntax for variable substitution.
Example Template:
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Hello {{name}}!</h1>
<p>Thank you for registering.</p>
{{#if link}}
<a href="{{link}}">Activate your account</a>
{{/if}}
</body>
</html>
Variable Sources:
--data '{"name":"value"}' JSONconfig.toml with passwords to version controlconfig.toml{{variable}}file1.pdf;file2.jpg<csv_file>.progress.progress file to start freshSee examples.sh for comprehensive command examples and CSV-FORMAT.md for detailed CSV format reference.
This project is provided as-is for educational and internal use.