App Logo
mail.google.com

unsubscribe_from_sender

Unsubscribe from a mailing list using Gmail's own unsubscribe control, which appears beside the sender on a message carrying a List-Unsubscribe header. Returns the sender it acted on, whether the control was present, and whether Gmail confirmed the request. This leaves the mailing list for real and cannot be undone from Gmail: confirm the exact sender with the user before running, and note that approval for one sender does not carry over to another. Senders with no unsubscribe control are reported rather than acted on, and the script never falls back to reporting spam.

Input

threadId required

A thread from the sender to unsubscribe from, as returned by mail.google.com/search_emails (its threadId field).

expectedSender required

The sender address the thread is expected to be from, asserted against the message before anything is clicked, so a stale thread id cannot unsubscribe you from the wrong list.

account optional

Optional authuser value for a browser signed into several Google accounts. Omit for the default (u/0).

Output

sender required

The sender address read from the message, not echoed from the input.

threadId required
unsubscribed required

Whether the unsubscribe was confirmed to Gmail.

control_present required

Whether Gmail offered an unsubscribe control for this sender at all.

link_gone optional

Whether the unsubscribe control disappeared afterwards, which is Gmail's own signal that the request was accepted.

confirmation optional

Gmail's own wording after confirming, quoted for the record rather than matched against.

Start building not clicking