Mailset can post what became of each message your product sends with a MAILSET_KEY to one webhook on your server, so you hear when a receipt bounces or a sign-in code expires. Replace example.com with your domain.
What you get
One event per recipient, in signed batches of up to 100: { "events": [...] }.
queued: a limit holds it.sendsAtsays when it should go out andreasonsays why.sent: the provider took it.delivered: the recipient's server took it.bounced: it came back.bounce.kindishardorsoft, andbounce.classsays what it means for the address:mailboxanddomainmean it can't get mail.complained: the recipient marked it as spam. Stop writing to them.failed: Mailset couldn't send it. The provider refused it, its app key was paused, or five tries failed.expired: itsdeliverBycame while it waited, so it never went.unsubscribed: the recipient used Mailset's unsubscribe link in your promotional mail. Mailset skips that mailbox's promotional mail to them from now on, so take them off your list too.
Each carries id, type, at (ms), message (the id that send answered), messageId (the Message-ID header), recipient and app (the key's name). Never a subject or anything from the body. On unsubscribed, message and messageId name the mail whose link they used. mailset hooks test sends a test event, which is about no message.
Steps
Install the CLI and sign in
Sign inSign in with a passkey
Press Sign in with a passkey and approve it on this device, your phone or a password manager. Mailset has no passwords.
The command
Install the CLI on macOS or Linux with
brew install intenseloop/tap/mailsetornpm install -g @mailset/cli.Run
mailset login, open the link it prints and approve with your passkey.In a terminal, login also offers your agents the Mailset skill;
mailset agents adddoes it later.Install the CLI on macOS or Linux with
brew install intenseloop/tap/mailsetornpm install -g @mailset/cli.Run
mailset login, open the link it prints and approve with your passkey.In a terminal, login also offers your agents the Mailset skill;
mailset agents adddoes it later.Pick a public https URL
Pick an https URL on your server, on port 443, under a public host name such as hooks.example.com.
Mailset refuses IP addresses, private network names (
localhost,.internal,.local) and URLs with a login in them, and connects only to a public address the name resolves to.Set the hook, keep its secret
SettingsDevelopersHook URL
Paste your https URL into Hook URL and press Set the hook. Copy the signing secret it shows once into your secret store.
The command
Run
mailset hooks set --url https://hooks.example.com/mailset. It prints the signing secret once. Keep it in your secret store asMAILSET_HOOK_SECRET.Run
mailset hooks set --url https://hooks.example.com/mailset. It prints the signing secret once. Keep it in your secret store asMAILSET_HOOK_SECRET.Verify and keep each event
Check each request with the SDK and keep the events.
A service that only receives them needs no
MAILSET_KEY.Every event's fields, a test vector and a verifier for Python, Go, Ruby, PHP and Java are at mailset.app/docs/webhooks:
import { webhooks } from 'mailset'; const events = await webhooks.verify({ body: await request.text(), headers: request.headers, secret: process.env.MAILSET_HOOK_SECRET, });Send yourself a test event
SettingsDevelopersSend a test
Press Send a test. Mailset posts one signed test event to your hook now and says whether your server took it, or what went wrong.
The command
Run
mailset hooks test. It posts one signedtestevent now and says what your server answered, up to 5 times a minute.Run
mailset hooks test. It posts one signedtestevent now and says what your server answered, up to 5 times a minute.
Check
mailset hooks get shows where events go, how many wait for your server, and why the last batch didn't go if one failed.
Watch out
- Answer 2xx once you've kept the events. Until you do, Mailset posts the same batch again, with the same
Mailset-Deliveryand event ids, for three days, then drops it and tells whoever set the hook. - Dedupe on
id. The same message, recipient and happening always has the same id, even when the provider reports it twice. Anunsubscribedevent comes once per opt-out, and someone you let back in who leaves again has a new id. - Mailset doesn't follow redirects: a 3xx counts as not taken, so set the new URL when a hook moves. Mailset reads nothing of your server's answer but its status, and gives up on a post after 15 seconds.
- Pass the body exactly as it arrived. The signature covers those bytes, and one older than 5 minutes is refused, so a captured request can't be replayed later.
mailset hooks rotatemakes a new secret and the old one stops at once.mailset hooks removestops the events and drops what was waiting.- Only mail an app key sends has events. Campaigns have their own hook:
mailset campaigns hook set.