New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
DeliverabilityUpdated 4 Nov 2026

One-Click Unsubscribe: List-Unsubscribe and List-Unsubscribe-Post Setup

How to implement RFC 8058 one-click unsubscribe: the exact headers, the HTTPS endpoint that must handle the POST, DKIM signing requirements, a working code example and the mistakes that break it.

TK
Written by Tomasz Kowalski
Infrastructure and Reliability Engineer
Reviewed by Lena Fischer
  • Published10 Dec 2023
  • Read time8 min
  • Length1,564 words
Share this guide

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.

HeadersList-Unsubscribe with an HTTPS URL, plus List-Unsubscribe-Post: List-Unsubscribe=One-Click
SigningDKIM must cover both headers; the RFC requires it
EndpointAccepts POST with body List-Unsubscribe=One-Click and returns 2xx, no login or confirmation
Still neededA visible unsubscribe link in the message body

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-Click

The 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

RequirementDetailWhy
HTTPS URL in List-UnsubscribeOne HTTPS URI must be presentClient sends the POST there
List-Unsubscribe-Post headerExact value List-Unsubscribe=One-ClickSignals one-click support
DKIM signature covering both headersBoth header names appear in the h= list of a valid DKIM-SignatureRFC 8058 requires it so the headers cannot be forged
One POST processed immediatelyNo confirmation, login or redirect requiredThe user clicked once
Stable, unguessable URLPer recipient tokenPrevent abuse and mass unsubscribes
Visible unsubscribe link in bodyPlain, easy to findUsers and regulators expect it. See unsubscribe pages
Quick processingGoogle asks for requests to be processed within two daysFaster 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

  1. Send a message to a Gmail test address and open Show original. Confirm both headers are present and DKIM passes.
  2. Check the signed header list (h=) for both header names.
  3. 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.
  4. Simulate the client POST yourself and confirm a 2xx response and a recorded suppression.
  5. Confirm the address is excluded from the next send.
  6. 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 msg

If 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

ProblemCauseFix
No unsubscribe button appearsHeaders missing, DKIM not covering them or sender has weak reputationInspect the original message and sign both headers
Endpoint returns 302 or 401Redirects or login requiredReturn 200 directly, no auth, no redirect
Endpoint returns 405Only GET implementedAccept POST on the URL
People unsubscribed without clickingGET handler unsubscribes; scanners fetched the linkMake GET non-destructive
Same recipient receives mail afterwardsSuppression delayed or not shared across systemsProcess immediately and sync to every sending system
HTTP URL usedInsecure URLUse HTTPS only
Header added to transactional mailTemplate shared across streamsLimit 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.

Explore the email API

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.

Topics#unsubscribe#list-unsubscribe#rfc 8058#headers#compliance
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales