Guides Amazon SES
How to add one-click unsubscribe to Amazon SES email

By Alejandro Medina
Published
Short answer
Gmail and Yahoo want two headers on each marketing email: List-Unsubscribe: <https://...> and List-Unsubscribe-Post: List-Unsubscribe=One-Click. On Amazon SES you have two ways to add them. Let SES do it with subscription management (ListManagementOptions and a contact list), or add the headers yourself with the Headers field of SendEmail and answer the POST on your own server.
What do Gmail and Yahoo ask for?
Both providers ask bulk senders for one-click unsubscribe on marketing email. In practice that means two headers:
List-Unsubscribe: <https://example.com/unsubscribe/7f3c9a>
List-Unsubscribe-Post: List-Unsubscribe=One-Click
The mail client shows an Unsubscribe button next to your name. When the reader clicks it, the provider sends a POST to the URL in the first header. Nobody opens a page, and nobody logs in.
| Provider | What it asks | Source |
|---|---|---|
| Senders of more than 5,000 messages a day support one-click unsubscribe on marketing and subscribed messages, and show a visible unsubscribe link in the body. | Email sender guidelines | |
| Yahoo | A working List-Unsubscribe header with one-click support. RFC 8058 POST is "highly recommended". Honor unsubscribes within 2 days. | Sender best practices |
RFC 8058 adds one more rule: the DKIM signature of the message must cover the List-Unsubscribe and List-Unsubscribe-Post headers. The test step below shows how to check that.
Option 1: Let SES manage the unsubscribes
SES has its own subscription management. You keep a contact list in SES, and you name it on each send. SES then adds both headers, hosts the unsubscribe page, and refuses to send to people who left.
Create the contact list
aws sesv2 create-contact-list --cli-input-json '{
"ContactListName": "newsletter",
"Topics": [
{ "TopicName": "updates", "DisplayName": "Product updates",
"Description": "One email when we ship something.",
"DefaultSubscriptionStatus": "OPT_IN" }
]
}'
Send with ListManagementOptions
aws sesv2 send-email \
--from-email-address news@example.com \
--destination ToAddresses=ana@example.com \
--list-management-options ContactListName=newsletter,TopicName=updates \
--content 'Simple={Subject={Data=November update},Body={Html={Data="<p>Hello Ana</p><p><a href=\"{{amazonSESUnsubscribeUrl}}\">Unsubscribe</a></p>"}}}'
The {{amazonSESUnsubscribeUrl}} placeholder becomes the footer link. SES replaces it at most twice in one email.
The limits to know first
These come from the AWS pages on list and subscription management:
- One contact list for each AWS account, with at most 20 topics.
- SES adds the headers and the footer link only when the email has a single recipient. Send one email for each contact.
- It works with Easy DKIM. If you sign the email yourself before SES gets it, SES cannot add the links.
- If the email already has
List-Unsubscribeheaders, SES replaces them. - SES hosts the unsubscribe page. You can change its topics, not its design.
- When you send to an address that unsubscribed, SES issues a bounce event instead. Your app learns about unsubscribes through configuration set notifications.
Option 1 is a good fit for an app that sends one kind of newsletter and keeps its list in SES anyway. If your list lives in your own database, option 2 is simpler.
Option 2: Add the headers yourself
The SES API v2 SendEmail call takes a Headers list on a simple message, with up to 15 headers. Put your own unsubscribe URL in it. Use one token per contact, so the URL alone tells your server who clicked.
{
"FromEmailAddress": "news@example.com",
"Destination": { "ToAddresses": ["ana@example.com"] },
"Content": {
"Simple": {
"Subject": { "Data": "November update" },
"Body": { "Html": { "Data": "<p>Hello Ana</p><p><a href=\"https://example.com/unsubscribe/7f3c9a\">Unsubscribe</a></p>" } },
"Headers": [
{ "Name": "List-Unsubscribe", "Value": "<https://example.com/unsubscribe/7f3c9a>" },
{ "Name": "List-Unsubscribe-Post", "Value": "List-Unsubscribe=One-Click" }
]
}
}
}
aws sesv2 send-email --cli-input-json file://email.json
If you send raw MIME (Content.Raw) or through the SES SMTP interface, write the same two lines into the message headers.
Answer the POST
Your endpoint must accept a POST from the mail provider. The provider sends no cookies and no CSRF token, so this route needs no session and no login. A short Node example with Express:
import express from 'express'
const app = express()
app.use(express.urlencoded({ extended: false }))
// One-click unsubscribe (RFC 8058). The provider POSTs "List-Unsubscribe=One-Click".
app.post('/unsubscribe/:token', async (req, res) => {
await unsubscribeByToken(req.params.token) // Mark the contact. Doing it twice changes nothing.
res.status(200).send('Unsubscribed')
})
// A person who clicks the link in the body gets a page with a confirm button.
// Link scanners open every link with GET, so a GET must not unsubscribe anyone.
app.get('/unsubscribe/:token', (req, res) => {
res.send(confirmPage(req.params.token))
})
Two rules keep this safe:
- A GET changes nothing. Security scanners and mail clients open links in email. If a GET unsubscribes, people leave your list without knowing it.
- The POST is idempotent. Providers can retry. The second request must give the same result.
How do you test the headers?
- Send a test email to a Gmail address.
- In Gmail, open the message, choose More, then Show original.
- Find both
List-Unsubscribelines. - Find the
DKIM-Signatureheader for your domain. Itsh=tag lists the signed headers.list-unsubscribeandlist-unsubscribe-postmust be in it.
Then call your endpoint the way a provider does:
curl -i -X POST https://example.com/unsubscribe/7f3c9a \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data 'List-Unsubscribe=One-Click'
A 200 and a contact marked as unsubscribed means the path works. Gmail does not show the button on every message, even when the headers are correct. The provider decides when to show it, so test the headers and the endpoint, not the button.
How BYOMailer handles this
BYOMailer adds both headers to each newsletter and sequence email, with a link for each email: /one-click-unsubscribe/<uuid>. The POST unsubscribes the contact, removes its pending emails and its sequences, and returns 200. A GET on the same link shows the normal unsubscribe page with a confirm button. The headers are there even when your content has no {{ unsubscribe_url }} link, and BYOMailer warns you before the send when that link is missing. The unsubscribe docs have the details.
Questions
Does Amazon SES add a List-Unsubscribe header by default?
No. SES adds the List-Unsubscribe and List-Unsubscribe-Post headers when you send with ListManagementOptions (subscription management). Without it, you add the headers yourself.
Who must support one-click unsubscribe?
Google says that senders of more than 5,000 messages a day must support one-click unsubscribe on marketing and subscribed messages. Yahoo asks bulk senders for a working List-Unsubscribe header and to honor unsubscribes within 2 days.
Do I still need an unsubscribe link in the body?
Yes. Google asks for a clearly visible unsubscribe link in the message body as well as the headers.
Can I use SES subscription management for a newsletter to many people?
SES adds the headers and footer links only when the email goes to a single recipient, so send one email per contact. The account can have only one contact list, with up to 20 topics.
What must my unsubscribe endpoint do?
Accept a POST with the body List-Unsubscribe=One-Click, with no cookies and no login, unsubscribe the address, and return a 2xx status. A second POST must change nothing.
Sources
- Google: Email sender guidelines
- Yahoo: Sender best practices
- AWS: Using subscription management
- AWS: Using list management
- AWS: SES API v2, Message type (Headers)
- RFC 8058: Signaling one-click functionality for list email headers
Products change. Spot a fact that's out of date? Open an issue in the code repository and I'll fix it.