Home > OS >  Gmail automated unsubscribe emails - How to stop them?
Gmail automated unsubscribe emails - How to stop them?

Time:04-13

When a user unsubscribes from an email in gmail, it seems gmail sends an email to the sender with:

`subject`: "unsubscribe"
`body`: "This message was automatically generated by Gmail."
`to`: u (somesuperlongrandomstring)@domain.tld
`from`: (Email of user who unsubscribed)

Similarly, when a user unsubscribes from an email in Apple Mail, it seems Apple Mail sends an email to the sender with:

`subject`: (blank)
`body`: Apple Mail sent this email to unsubscribe from the message "(Subject of email unsubscribed from)".
`to`: u (somesuperlongrandomstring)@domain.tld
`from`: Email of user who unsubscribed

We use mailgun to handle unsubscribes already, but as of 28th March 2022, these emails from both providers now make it through our email routing.

Does anyone know how to tell gmail or Apple Mail to not send these emails? They are redundant because mailgun is already handling the unsubscribe using the list-unsubscribe header as you'd expect.

Alternatively, does anyone know how to set up Mailgun so these messages aren't passed through routes?

CodePudding user response:

So Mailgun didn't provide any help, sadly. But looking through their documentation, and the headers of these emails, it seems possible to use their Routes to hide the emails completely.

The three clues are:

  • Emails always coming in the format u (...)@domain.tld
  • Gmail unsubscribes always have the subject "unsubscribe"
  • Apple Mail unsubscribes always have the header: X-Apple-Unsubscribe:true

As such, you can create a route as such to capture and discard these emails using a custom route with the raw expression set to:

match_recipient("u (.*)@domain.tld") and (match_header("X-Apple-Unsubscribe", "true") or match_header('subject', 'unsubscribe'))

It's sad that Mailgun stopped doing this themselves, but at least there is a solution with their tooling!

  • Related