{"id":50672063,"url":"https://github.com/franzos/polymail-rs","last_synced_at":"2026-06-08T12:04:14.072Z","repository":{"id":358093088,"uuid":"1194063813","full_name":"franzos/polymail-rs","owner":"franzos","description":"Rust library to send emails using Postmark, Lettermind and Sendgrid","archived":false,"fork":false,"pushed_at":"2026-04-11T09:29:46.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-15T19:45:52.417Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/franzos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-27T22:03:05.000Z","updated_at":"2026-04-11T09:29:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/franzos/polymail-rs","commit_stats":null,"previous_names":["franzos/polymail-rs"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/franzos/polymail-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzos%2Fpolymail-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzos%2Fpolymail-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzos%2Fpolymail-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzos%2Fpolymail-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/franzos","download_url":"https://codeload.github.com/franzos/polymail-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/franzos%2Fpolymail-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34061125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-08T12:04:11.243Z","updated_at":"2026-06-08T12:04:14.036Z","avatar_url":"https://github.com/franzos.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polymail\n\n[![ci](https://github.com/franzos/polymail-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/franzos/polymail-rs/actions/workflows/ci.yml)\n[![crates.io](https://img.shields.io/crates/v/polymail.svg)](https://crates.io/crates/polymail)\n[![Documentation](https://docs.rs/polymail/badge.svg)](https://docs.rs/polymail)\n\nUnified email sending interface for Rust. Write your email once, send it through any supported provider — swap providers by changing one line.\n\nCurrently supported: [Lettermint](https://lettermint.co), [Postmark](https://postmarkapp.com), [SendGrid](https://sendgrid.com).\n\n## Usage\n\n```toml\n[dependencies]\npolymail = { version = \"0.1\", features = [\"lettermint\"] }\ntokio = { version = \"1\", features = [\"rt\", \"macros\"] }\n```\n\nLettermint is the default feature, so `features = [\"lettermint\"]` can be omitted.\n\n### Send an email\n\n```rust,ignore\nuse polymail::{Email, Body, Mailer};\nuse polymail::provider::lettermint::LettermintMailer;\n\n#[tokio::main]\nasync fn main() {\n    let mailer = LettermintMailer::new(\"your-api-token\");\n\n    let email = Email::builder(\"sender@yourdomain.com\", \"Hello\", Body::Text(\"Hi there!\".into()))\n        .to(\"recipient@example.com\")\n        .build()\n        .unwrap();\n\n    let result = mailer.send(\u0026email).await.unwrap();\n    println!(\"Sent: {:?}\", result.message_id);\n}\n```\n\n### HTML + text with all options\n\n```rust,ignore\nuse polymail::{Email, Body, Address, Attachment, Mailer};\nuse polymail::provider::lettermint::LettermintMailer;\n\nasync fn send_full(mailer: \u0026LettermintMailer) {\n    let email = Email::builder(\n            Address::with_name(\"jane@yourdomain.com\", \"Jane\"),\n            \"Monthly update\",\n            Body::Both {\n                html: \"\u003ch1\u003eUpdate\u003c/h1\u003e\u003cp\u003eHere's what happened.\u003c/p\u003e\".into(),\n                text: \"Here's what happened.\".into(),\n            },\n        )\n        .to(\"user@example.com\")\n        .cc(\"team@example.com\")\n        .bcc(\"archive@example.com\")\n        .reply_to(\"support@yourdomain.com\")\n        .header(\"X-Campaign\", \"monthly-update\")\n        .attachment(Attachment {\n            filename: \"report.pdf\".into(),\n            content: \"\u003cbase64-encoded-content\u003e\".into(),\n            content_type: \"application/pdf\".into(),\n            content_id: None,\n        })\n        .tag(\"newsletter\")\n        .metadata(\"campaign_id\", \"2025-03\")\n        .build()\n        .unwrap();\n\n    let result = mailer.send(\u0026email).await.unwrap();\n    println!(\"{:?}\", result);\n}\n```\n\n### Batch sending\n\nProviders with native batch support send all emails in a single API call. Others fall back to sequential sends.\n\n```rust,ignore\nuse polymail::{Email, Body, BatchItemResult, Mailer};\nuse polymail::provider::lettermint::LettermintMailer;\n\nasync fn send_batch(mailer: \u0026LettermintMailer) {\n    let emails: Vec\u003cEmail\u003e = vec![\n        Email::builder(\"sender@yourdomain.com\", \"Hello Alice\", Body::Text(\"Hi Alice!\".into()))\n            .to(\"alice@example.com\")\n            .build()\n            .unwrap(),\n        Email::builder(\"sender@yourdomain.com\", \"Hello Bob\", Body::Text(\"Hi Bob!\".into()))\n            .to(\"bob@example.com\")\n            .build()\n            .unwrap(),\n    ];\n\n    let results = mailer.batch_send(\u0026emails).await.unwrap();\n    for (i, result) in results.iter().enumerate() {\n        match result {\n            BatchItemResult::Success(r) =\u003e println!(\"#{i}: sent {:?}\", r.message_id),\n            BatchItemResult::Failed(e) =\u003e println!(\"#{i}: failed {e}\"),\n        }\n    }\n}\n```\n\n### Switching providers\n\n```rust,ignore\nuse polymail::{Email, Body, Mailer};\nuse polymail::provider::postmark::PostmarkMailer;\n\nlet mailer = PostmarkMailer::new(\"your-server-token\");\n// Same Email, same .send() call — just a different mailer.\n```\n\n### Fallback across providers\n\n`FallbackMailer` tries providers in order. On transient failures (network issues, rate limits, service outages), it moves to the next provider. On permanent failures (invalid address, hard bounce), it returns immediately — retrying won't help.\n\n```rust,ignore\nuse polymail::{FallbackMailer, Mailer};\nuse polymail::provider::lettermint::LettermintMailer;\nuse polymail::provider::postmark::PostmarkMailer;\n\nlet mailer = FallbackMailer::new(vec![\n    Box::new(LettermintMailer::new(\"lettermint-token\")),\n    Box::new(PostmarkMailer::new(\"postmark-token\")),\n]);\n\n// Tries Lettermint first; if it's down, sends through Postmark.\nlet result = mailer.send(\u0026email).await?;\n```\n\n`FallbackMailer` implements `Mailer`, so it works anywhere a single provider does — including `Box\u003cdyn Mailer\u003e`.\n\nErrors that trigger fallback:\n\n| Error | Fallback? | Reason |\n|---|---|---|\n| `Provider` | yes | Transport failure (network, TLS, timeout) |\n| `RateLimitExceeded` | yes | Provider-specific quota, next provider may accept |\n| `ServiceUnavailable` | yes | Provider is down |\n| `Authentication` | yes | Bad key for this provider, next may work |\n| `InvalidAddress` | no | Bad email, will fail everywhere |\n| `InactiveRecipient` | no | Recipient-level suppression |\n| `SpamComplaint` | no | Recipient-level suppression |\n| `HardBounce` | no | Recipient-level suppression |\n| `Serialization` | no | Client-side bug |\n\n### Using as a trait object\n\n```rust,ignore\nuse polymail::Mailer;\nuse polymail::provider::lettermint::LettermintMailer;\n\nfn get_mailer() -\u003e Box\u003cdyn Mailer\u003e {\n    Box::new(LettermintMailer::new(\"token\"))\n}\n```\n\n## Features\n\n| Feature | Default | Description |\n|---------|---------|-------------|\n| `lettermint` | yes | Lettermint provider |\n| `postmark` | no | Postmark provider |\n| `sendgrid` | no | SendGrid provider |\n\nEnable multiple providers at once:\n\n```toml\npolymail = { version = \"0.1\", features = [\"lettermint\", \"postmark\"] }\n```\n\n## Provider capabilities\n\n| Capability | Lettermint | Postmark | SendGrid |\n|---|---|---|---|\n| Single send | yes | yes | yes |\n| Batch send (native) | yes (up to 500) | yes (up to 500) | no (sequential fallback) |\n| Attachments | yes | yes | yes |\n| Inline attachments | yes | yes | yes |\n| Custom headers | yes | yes | yes (per-personalization) |\n| Multiple reply-to | yes | first only | first only |\n| Tags | first tag | first tag | multiple (categories) |\n| Metadata | yes | yes | yes (as custom args) |\n\n## Error handling\n\nProvider-specific errors are mapped to shared `SendError` variants so you can handle common failure modes without matching on providers:\n\n```rust,ignore\nuse polymail::{Mailer, SendError};\n\nmatch mailer.send(\u0026email).await {\n    Ok(result) =\u003e println!(\"sent: {:?}\", result.message_id),\n    Err(SendError::RateLimitExceeded(_)) =\u003e println!(\"back off and retry\"),\n    Err(SendError::Authentication(_)) =\u003e println!(\"check your API key\"),\n    Err(SendError::InvalidAddress(msg)) =\u003e println!(\"bad address: {msg}\"),\n    Err(e) =\u003e println!(\"other error: {e}\"),\n}\n```\n\n### Error mapping by provider\n\n| `SendError` | Postmark | Lettermint | SendGrid |\n|---|---|---|---|\n| `Authentication` | — | HTTP 401/403 | HTTP 401/403 |\n| `InvalidAddress` | error code 300 | HTTP 422 (validation) | HTTP 400 |\n| `InactiveRecipient` | error code 406 | batch status | — |\n| `SpamComplaint` | error code 409 | batch status | — |\n| `HardBounce` | error code 422 | batch status | — |\n| `RateLimitExceeded` | error code 429 | HTTP 429 | HTTP 429 |\n| `ServiceUnavailable` | error codes 500–504 | HTTP 5xx | HTTP 500–504 |\n| `Provider` | transport errors | transport/parse errors | transport/parse errors |\n| `Api` | other error codes | other HTTP errors | other HTTP errors |\n\n## Testing\n\n```sh\ncargo test --all-features\n```\n\n## License\n\nDual-licensed under MIT or Apache 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranzos%2Fpolymail-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranzos%2Fpolymail-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranzos%2Fpolymail-rs/lists"}