Send email from Rust with reqwest.
From Rust the integration is the JSON API: a serde struct for the payload and one reqwest call. Build the client once with a timeout, send an idempotency key with each message, and verify webhooks with an HMAC over the raw body.
Send an email from Rust.
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(10))
.build()?;
let response = client
.post("https://app.usenotix.dev/api/v1/emails")
.bearer_auth(std::env::var("NOTIX_API_KEY")?)
.header("Idempotency-Key", "order-4471-receipt")
.json(&serde_json::json!({
"from": "Acme <receipts@acme.com>",
"to": "maria@example.com",
"subject": "Your receipt",
"html": "<p>Thanks for your order.</p>"
}))
.send()
.await?;
The from address must be on a domain you have verified in Notix. Step by step: the cURL quickstart and the longer guide to sending email from Rust.
One API key, kept on the server.
Create an API key on the API keys page of the Notix console and store it as NOTIX_API_KEY in the process environment. Read it only in code that runs on the server, never in anything shipped to a browser.
A Send only key is enough for code that only sends: if it leaks, it cannot read your contacts or delete a domain.
NOTIX_API_KEY=notix_xxxxxxxxxxxx
NOTIX_WEBHOOK_SECRET=whsec_xxxxxxxxxxxx
Verify the signature yourself.
Without an SDK, compute v1= plus the hex HMAC-SHA256 of the X-Notix-Timestamp header, a dot and the raw body, with your signing secret; compare it with X-Notix-Signature in constant time and refuse a timestamp more than 5 minutes old.
Read the body as bytes in your web framework's handler, before deserialising it.
Questions, answered.
Is there a Notix SDK for Rust?
What if the same request runs twice?
Why is my send refused with a from-address error?
Send your first email in five minutes.
Verify a domain, copy an API key, make one call. The free plan does not ask for a card.