How does the Gmail unsubscribe button work?

栏目: IT技术 · 发布时间: 4年前

内容简介:If you use Gmail or frequently send mailing list emails you probably know that Gmail has an inline automatic unsubscribe button. If you hit this button then Gmail magically unsubscribes you from that mailing list.I've spoken about this beforeSo in this pos

If you use Gmail or frequently send mailing list emails you probably know that Gmail has an inline automatic unsubscribe button. If you hit this button then Gmail magically unsubscribes you from that mailing list.

How does the Gmail unsubscribe button work?

I've spoken about this before on Twitter but although it seems counterintuative, allowing people to easily unsubscribe is the best way to maintain a healthy mailing list.

So in this post I want to disect exactly how the Gmail unsubscribe button works, and if you're a mailing-list owner, how to make sure it always shows up for your emails.

How does the Gmail unsubscribe button work?
https://twitter.com/dhh/status/1233051661796438017

There are a few ways to provide unsubscribe links, when used properly they compliment each other by letting every type of client unsubscribe easily. Starting with the most obvious (and often infuriating)...

Unsubscribe links in the email content

The most common method you'll see everywhere is to provide an unsubscribe link directly within the email content, usually hidden away at the bottom of the email.

How does the Gmail unsubscribe button work?

Gmail seems to handle some of these links, specifically when the link contains the word "Unsubscribe".  Clicking the Gmail unsubscribe link using the case above shows the following prompt:

How does the Gmail unsubscribe button work?

But I found if the link contains unusual wording or formatting then Gmail doesn't find it correctly. A likely explanation is they're using a set of regular expressions to parse the email content - quite a brittle approach.

You're also still required to actually visit the link in most cases we tried, which limits it's usefulness somewhat. It's barely easier than finding and clicking the small unsubscribe link in the email.

(It's probably obvious by now - I do have some strong feelings about tiny unsubscribe links skulking right at the bottom of email footers, but that's a topic for another day.)

How does the Gmail unsubscribe button work?

Enjoying this post? Let us know on Hacker News!

List-Unsubscribe

A more predictable approach is to use the List-Unsubscribe header ( RFC 2369 ). Attached to the metadata of an email, the header is designed to provide the method to unsubscribe in a machine readable format.

How does the Gmail unsubscribe button work?
The source of a Substack email

The header can have a number of different formats, but the most common is to provide a mailto and URL like this:

List-Unsubscribe: 
  <mailto:<a href="/cdn-cgi/l/email-protection" data-cfemail="a2d6c7d1d6e2c7dac3cfd2cec78cc1cdcf">[email protected]</a>>, 
  <https://example.com/unsubscribe?uid=0000>

If you're using a mailing list provider such as Sendgrid or Mailchimp then they should already insert these headers into the email for you, so you shouldn't need to do anything extra with this.

It appears from testing that Gmail will favour the mailto method, sending an email to the address provided. You can verify this by checking your sent email folder, which will contain items like this;

How does the Gmail unsubscribe button work?

This is by far the simplest approach, sending an email is what Gmail is good at after all. However, I'm somewhat sceptical of the effectiveness of this method, or maybe it just feels too easy.

As far as I can tell Gmail treats URLs in the List-Unsubscribe header identically to unsubscrbe links in the content of emails, which makes sense as they should be the same URL in most cases.

List-Unsubscribe-Post

One problem with List-Unsubscribe or content links is they could take you to a page that requires extra steps, such as logging in or entering your email address. Despite how you feel about this (I dislike it a lot), it makes things very difficult to automate an unsubscribe like Gmail is trying to do.

However, there's a newer unsubscribe standard header called List-Unsubscribe-Post that designates single-request unsubscribe functionality ( RFC 8058 ). If an email contains this header then the unsubscribe link can simply be activated by sending a single POST request to the URL.

How does the Gmail unsubscribe button work?

Unfortunately it's much less common than List-Unsubscribe to see in the wild. I could actually only find one example of this in my inbox (shout out to Substack , nice work folks).

As far as I can tell Gmail does nothing with this header, but it's a nice-to-have on your mailing list if you want to cover all the bases.

That about wraps it up for our unsubscribe options. If you're running a mailing list and want to make it easy for your recipients to unsubscribe (you should), then implementing these things will be a great addition and help you maintain a healthy list in the long run:

  1. Include an unsubscribe link in the content of the email in a clear, legible way, using simple language. Using the word "Unsubscribe" in the link is probably a good idea.
  2. Include a List-Unsubscribe header with a mailto and URL. If you're using a mail service, make sure they are including this automatically. You can check the source of an email to do this - here's a guide on how to do that.
  3. Where possible make your unsubscribe link work with a single click!

PS.

One extra thing I found out was that Gmail doesn't seem to show the unsubscribe button until you've received a few emails from a particular sender. This makes sense I suppose, but seemed to behave quite unpredicably.

Also for some emails it just straight up doesn't show the button and I couldn't find an explanation. Perhaps there's some extra step going on behind the scenes or something I'm missing.

If you know the answer to either of these unknowns then let me know on the HN thread and I'll credit you here :)

How does the Gmail unsubscribe button work?

If you're looking for a more effective way to unsubscribe in bulk then I run a service calledLeave Me Alone. With it you can see all your mailing lists in one place and unsubscribe from them with a single click.

We use all the methods listed above and more to unsubscribe, meaning we're much more effective than the Gmail unsubscribe button ;)

Try it out for free

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

同伦方法纵横谈

同伦方法纵横谈

王则柯 / 大连理工大学 / 2011-5 / 25.00元

《走向数学丛书07-同伦方法纵横谈》,在本书里读者会看到许多人物故事,作为一本普及读物,我们有时候甚至觉得,对于不少读者来说,书中所写的科学研究中的人物故事,可能比书中介绍的具体的研究成果更有价值,这些人物故事,许多都出自我们个人之间的交往,这是从一个侧面了解科学研究的规律,了解科学家之成为科学家的珍贵记录。一起来看看 《同伦方法纵横谈》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具