One-click unsubscribe means your message carries two headers, List-Unsubscribe with an HTTPS URL and List-Unsubscribe-Post: List-Unsubscribe=One-Click, so that a mail client can show an unsubscribe button and unsubscribe the user with a single HTTP POST, with no confirmation page or login. The mechanism is defined in RFC 8058 and builds on the List-Unsubscribe header from RFC 2369. Google and Yahoo require it for marketing and subscribed mail from bulk senders.
To implement it you need three things: the headers on every qualifying message, a DKIM signature that covers those headers, and an endpoint that accepts the POST, identifies the recipient from the URL and suppresses them quickly. Do those correctly and the button works in clients that support it. This guide covers each part with working examples.
What the two headers do
List-Unsubscribe (RFC 2369) offers one or more unsubscribe methods in angle brackets: a mailto address, an HTTPS URL, or both. List-Unsubscribe-Post (RFC 8058) tells the mail client that the HTTPS URL accepts an automated POST that performs the unsubscribe immediately. The client sends the POST on the user's behalf. The user never sees your website.
List-Unsubscribe: <https://example.com/u/Zm9vQGV4YW1wbGUub3Jn.k3J9xQ>, <mailto:[email protected]?subject=unsub-k3J9xQ>
List-Unsubscribe-Post: List-Unsubscribe=One-ClickThe HTTPS URL is mandatory for one-click. The mailto form is optional and remains useful for older clients. Never use an HTTP URL: RFC 8058 requires HTTPS. The URL should be unique per message or per recipient so the endpoint can identify who is unsubscribing without extra input.
Requirements checklist
| Requirement | Detail | Why |
|---|---|---|
| HTTPS URL in List-Unsubscribe | One HTTPS URI must be present | Client sends the POST there |
| List-Unsubscribe-Post header | Exact value List-Unsubscribe=One-Click | Signals one-click support |
| DKIM signature covering both headers | Both header names appear in the h= list of a valid DKIM-Signature | RFC 8058 requires it so the headers cannot be forged |
| One POST processed immediately | No confirmation, login or redirect required | The user clicked once |
| Stable, unguessable URL | Per recipient token | Prevent abuse and mass unsubscribes |
| Visible unsubscribe link in body | Plain, easy to find | Users and regulators expect it. See unsubscribe pages |
| Quick processing | Google asks for requests to be processed within two days | Faster is better; aim for immediate |
Apply the headers to marketing and subscribed mail. Google's requirement applies to promotional mail, while transactional mail such as password resets does not need an unsubscribe header. See Gmail and Yahoo requirements and transactional versus marketing email.
Build the endpoint
The client sends a POST to the URL with a body of List-Unsubscribe=One-Click (form encoded). Respond with a 2xx status. Accept the request without cookies or authentication, because the secret is the URL token. Here is a compact example using Node.js and Express. Adapt the storage calls to your system.
import express from 'express';
import crypto from 'node:crypto';
const app = express();
app.use(express.urlencoded({ extended: false }));
const SECRET = process.env.UNSUB_SECRET;
function verify(token) {
const [payload, sig] = token.split('.');
const expected = crypto.createHmac('sha256', SECRET)
.update(payload).digest('base64url').slice(0, 16);
const ok = sig && crypto.timingSafeEqual(
Buffer.from(sig.padEnd(16)), Buffer.from(expected.padEnd(16)));
return ok ? Buffer.from(payload, 'base64url').toString() : null;
}
// One-click: machine POST from the mail client
app.post('/u/:token', async (req, res) => {
const email = verify(req.params.token);
if (!email) return res.sendStatus(400);
if (req.body['List-Unsubscribe'] !== 'One-Click') return res.sendStatus(400);
await suppress(email, 'one-click'); // your function: idempotent
res.sendStatus(200);
});
// Human click on the same URL: show a confirmation page, do not unsubscribe on GET
app.get('/u/:token', (req, res) => {
res.send('<form method="post"><button>Confirm unsubscribe</button></form>');
});
app.listen(3000);Two design points matter. First, the POST must unsubscribe without further interaction. Second, a GET must never unsubscribe, because security scanners and link prefetchers fetch URLs automatically and would silently remove people. The GET handler above shows a confirmation form instead. Make the suppression idempotent, so repeated POSTs are harmless, and respond with success even if the person was already unsubscribed.
Sign the headers with DKIM
RFC 8058 says the message must have a valid DKIM signature that covers both List-Unsubscribe and List-Unsubscribe-Post. If the signature does not cover them, a client should not trust the one-click action. Make sure your signing configuration includes both in the signed header list. The result looks like this in the signature tag:
DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=s1; c=relaxed/relaxed;
h=from:to:subject:date:message-id:list-unsubscribe:list-unsubscribe-post;
bh=...; b=...If your platform adds the headers after signing, the signature will not cover them and one-click may not appear. Check the signed header list in a received message. See which headers to sign and DKIM failures.
Test it end to end
- Send a message to a Gmail test address and open Show original. Confirm both headers are present and DKIM passes.
- Check the signed header list (
h=) for both header names. - Look for the Unsubscribe option next to the sender name in the Gmail message view. Display of the control is up to the client and may take time or depend on sender reputation.
- Simulate the client POST yourself and confirm a 2xx response and a recorded suppression.
- Confirm the address is excluded from the next send.
- Send a second message to the unsubscribed address in a test environment and confirm it is blocked.
curl -i -X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data 'List-Unsubscribe=One-Click' \
'https://example.com/u/Zm9vQGV4YW1wbGUub3Jn.k3J9xQ'Generating the headers in an MTA or application
Where you add the headers depends on your stack. In an application using SMTP, add them to the message before it is handed to the relay, and confirm the relay signs after headers are final. In an MTA you control, add them in the message handling stage before DKIM signing runs. The order is the point: headers first, signature last. Here is a short Python example that builds a message with both headers.
from email.message import EmailMessage
def build(to_addr, token):
msg = EmailMessage()
msg['From'] = 'News <[email protected]>'
msg['To'] = to_addr
msg['Subject'] = 'Monthly update'
url = f'https://example.com/u/{token}'
msg['List-Unsubscribe'] = f'<{url}>, <mailto:[email protected]?subject=unsub>'
msg['List-Unsubscribe-Post'] = 'List-Unsubscribe=One-Click'
msg.set_content('Hello. You can unsubscribe at the link below.\n' + url)
return msgIf you send through a provider, check whether it adds these headers for you and how it signs them, and read its current documentation. Some providers manage the unsubscribe URL and process the POST themselves, which removes the need to host your own endpoint but means you must make sure their suppression list is respected by every other system that mails the same people.
Operating the endpoint
Treat the endpoint as production infrastructure. It must be available whenever a message might be opened, which can be days or weeks after sending, so keep old tokens valid. Log every request with timestamp, token identifier and result, but avoid storing more personal data than needed. Rate limit abuse without blocking the large mail providers that send the POST. Answer with a plain 200 and a short body; do not redirect, because many clients do not follow redirects for this request.
Tokens should be signed rather than a bare address in the URL, so nobody can unsubscribe other people by guessing. Do not expire tokens aggressively. If a token fails verification, return an error status and log it, but do not reveal whether an address exists on your list.
After the unsubscribe, synchronise the suppression to every system that can send to that person, including your marketing platform, your CRM and any application that triggers mail. A one-click button that only updates one system is a common source of complaints. Finally, review unsubscribe volume: a sudden spike after a campaign shows that the content or frequency needs work, and a complete absence of unsubscribes can mean the mechanism is not working.
Common mistakes and troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| No unsubscribe button appears | Headers missing, DKIM not covering them or sender has weak reputation | Inspect the original message and sign both headers |
| Endpoint returns 302 or 401 | Redirects or login required | Return 200 directly, no auth, no redirect |
| Endpoint returns 405 | Only GET implemented | Accept POST on the URL |
| People unsubscribed without clicking | GET handler unsubscribes; scanners fetched the link | Make GET non-destructive |
| Same recipient receives mail afterwards | Suppression delayed or not shared across systems | Process immediately and sync to every sending system |
| HTTP URL used | Insecure URL | Use HTTPS only |
| Header added to transactional mail | Template shared across streams | Limit to marketing and subscription mail |
Next steps
Add the headers in your sending platform or MTA, confirm DKIM coverage, deploy the endpoint with logging, and monitor unsubscribe and spam complaint rates, since a working unsubscribe lowers complaints. Keep the visible footer link and a preference centre for people who want fewer emails. See preference centre and suppression list management. Laws such as CAN-SPAM, CASL and GDPR also govern opt outs; this is not legal advice, so confirm obligations with a qualified adviser.
Add compliant unsubscribe headers to your mail Send through an SMTP relay or REST API with DKIM signing and suppression handling.
References and further reading
Frequently asked questions
What headers do I need for one-click unsubscribe?
A List-Unsubscribe header with an HTTPS URL and a List-Unsubscribe-Post header with the value List-Unsubscribe=One-Click.
Does DKIM have to sign the unsubscribe headers?
Yes. RFC 8058 requires a valid DKIM signature that covers both List-Unsubscribe and List-Unsubscribe-Post.
What should the unsubscribe endpoint return?
A 2xx status after processing the POST immediately, with no login, redirect or confirmation step required from the user.
Should a GET request unsubscribe the user?
No. Scanners and prefetchers issue GET requests, so GET should show a confirmation page and only POST should unsubscribe.
Do transactional emails need one-click unsubscribe?
Generally no. Google applies the requirement to marketing and subscribed mail, not to messages such as password resets.