Expand description
Rust client SDK for mailman, a microservice that sends emails on your behalf over SMTP.
Mailman ships as two things, mirroring geodude:
- an HTTP microservice that owns the SMTP credentials and sends mail, and
- a Rust client crate (this crate’s default
clientfeature) that other services use to ask it to send mail.
§Quickstart
Point at your mailman server once, then send mail from anywhere:
mailman::setup("https://mailman.example.com", "super-secret-token")?;
let email = mailman::SendEmailRequest::new(
"Hello from mailman",
"This one's plain text.",
["alice@example.com"],
);
mailman::send(&email).await?;Or read the URL and token from the environment (MAILMAN_URL and
MAILMAN_API_TOKEN):
let email = mailman::SendEmailRequest::new(
"Hello",
"<h1>Hi!</h1>",
["bob@example.com"],
)
.html(true)
.cc(["carol@example.com"]);
// `send` lazily falls back to MAILMAN_URL / MAILMAN_API_TOKEN on first
// call, so the env-only path can skip the init call entirely.
mailman::send(&email).await?;For multiple servers or finer control over the reqwest::Client, construct a
Client directly with Client::new or Client::with_http.
Structs§
- Attachment
- A single file attachment.
contentis the file’s bytes encoded as standard (RFC 4648) base64. - Client
- HTTP client for a mailman server.
- Error
Response - The JSON returned by mailman on error:
{"error": "..."}. - Send
Email Request - A request to send an email. This is the JSON body of
POST /send. - Send
Email Response - The JSON returned by
POST /sendon success.
Enums§
- Error
- Errors returned by the mailman client.
Functions§
- configured_
url - The configured base URL, if
setuporfrom_envhas run. - from_
env - Configure the process-global client by reading
MAILMAN_URLandMAILMAN_API_TOKEN. - send
- Send an email via the process-global client. Lazily initializes from
MAILMAN_URL/MAILMAN_API_TOKENon first call if not already configured. - setup
- Configure the process-global client with an explicit URL and token. The first successful call wins; subsequent calls are no-ops.