Your product names each message's kind with mode in the mailset SDK, and Mailset checks that the message has what that kind needs. Replace example.com with your domain.
transactional, the default: sign-in codes, receipts, alerts. It needs no unsubscribe, and Mailset refuses it if it carriesList-UnsubscribeorPrecedence: bulk: that's promotional mail under another name.promotional: newsletters, digests, offers. It goes to one address into, with noccorbcc. Mailset adds a one-clickList-Unsubscribeand puts the link where you write{{mailset_unsubscribe}}, or on a last line of each part when you don't.
Once someone uses that link, Mailset skips later promotional mail from that mailbox to them and your hook hears unsubscribed (mailset guide product-events). With a domain key the opt-out belongs to the sending domain, so promotional mail from any address on it skips them. Transactional mail still reaches them, and so does promotional mail from your other mailboxes and domains.
To run unsubscribes yourself, pass your own List-Unsubscribe: <https://...> and List-Unsubscribe-Post: List-Unsubscribe=One-Click in headers, with the same URL in the text and the HTML. Mailset then adds nothing, and honoring each opt-out is up to you. Campaigns sent through a campaigns key always bring their own.
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.Make your product’s key
SettingsDevelopersMake a key
Press Make a key, name it, pick a mailbox or a sending domain’s addresses and approve with your passkey. Copy the MAILSET_KEY it shows once.
The command
Make a key for your product's own mail:
mailset keys create --send --mailbox moc.elpmaxe@olleh --name "Example API".If example.com only sends through Mailset and its mail lives elsewhere, make the key for the domain instead, naming the addresses your product uses:
mailset keys create --send --domain example.com --from moc.elpmaxe@olleh --name "Example API".Make a key for your product's own mail:
mailset keys create --send --mailbox moc.elpmaxe@olleh --name "Example API".If example.com only sends through Mailset and its mail lives elsewhere, make the key for the domain instead, naming the addresses your product uses:
mailset keys create --send --domain example.com --from moc.elpmaxe@olleh --name "Example API".Give newsletters a subdomain
A sending-only domain is added with the command.
Send newsletters from a subdomain with a key of their own.
Add it as sending-only, since nobody reads mail there (
mailset domains add news.example.com --sending), put its records in DNS (mailset domains apply news.example.com --sending, ormailset guide dns-by-hand), and make its key:mailset keys create --send --domain news.example.com --from moc.elpmaxe.swen@swen --name "Example announcements".Nobody has an address there, so
--any-addressin place of--fromis fine too.Point
replyToat an inbox someone reads.Hand it to your agent
Send newsletters from a subdomain with a key of their own.
Add it as sending-only, since nobody reads mail there (
mailset domains add news.example.com --sending), put its records in DNS (mailset domains apply news.example.com --sending, ormailset guide dns-by-hand), and make its key:mailset keys create --send --domain news.example.com --from moc.elpmaxe.swen@swen --name "Example announcements".Nobody has an address there, so
--any-addressin place of--fromis fine too.Point
replyToat an inbox someone reads.Store both keys as secrets
Keep each printed
MAILSET_KEYin your secret store.Install the SDK and send
Install the SDK with
npm install mailsetand send.The docs have the rest: the SDK at mailset.app/docs/sdk, promotional mail and its unsubscribe at mailset.app/docs/recipes/unsubscribes, batches at mailset.app/docs/recipes/batches,
deliverByat mailset.app/docs/recipes/deadlines,idempotencyKeyat mailset.app/docs/recipes/retries, and a language with no SDK at mailset.app/docs/authentication/http.import { Mailset } from 'mailset'; // Reads MAILSET_KEY from the environment. const mailset = new Mailset(); await mailset.send({ from: 'Example <moc.elpmaxe@olleh>', to: 'gro.elpmaxe@ana', subject: 'Your Example code', text: 'Your code is 123456.', });Check the key once a day
Call
await mailset.key.check()when your server starts and once a day. A key unused for 90 days stops working.
Check
A refused message throws MailsetError with a stable code and a sentence saying what's missing. mailset delivery search --sender news.example.com shows what went out, and mailset unsubscribes list news.example.com shows who unsubscribed.
Watch out
- One key per kind of mail. Each key has its own brake, so a paused newsletter key never stops sign-in codes:
mailset guide brakes. A domain key covers its own domain only, never a subdomain, so news.example.com gets its own. - The subdomain matters too. A spam report stops mail to that person from the domain it was about, so a report on news.example.com never costs them a sign-in code from example.com.
- A sign-in code is useless an hour late. Give it
deliverBy: '10m', so a limit that would hold it longer refuses it at once, and one still waiting then is dropped:mailset guide sending-limits. - Mailset doesn't send product mail to Apple's Hide My Email addresses or to temporary inboxes, or promotional mail to someone who unsubscribed from that mailbox or domain. It doesn't throw either: the receipt's
skippednames each one with itsreason(private_relay,disposableorunsubscribed), everyone else gets the mail, and the delivery log saysskipped. Don't retry it. A skip never counts against the brake. - An unsubscribe holds until that person asks you for your mail again. Then run
mailset unsubscribes remove news.example.com --address gro.elpmaxe@ana, or name the mailbox for a mailbox key's mail.