0

I am using PEAR::Mail to send thousands of emails and everything is working correctly. In the footer of my emails I have this link for those who want to unsubscribe:

enter image description here

When someone clicks that link, I go to my database to remove that email address from my list of subscribers. However, I recently noticed that my Gmail account included this unsubscribe button next to the company name, below the subject line:

enter image description here

When someone unsubscribes by clicking that link, I guess Gmail makes sure the person does not receive emails from my server anymore, but the problem is that I have no way of knowing that to remove that user from my database. I do not want to keep in my database emails of people who do not want to receive my emails (those who have explicitly unsubscribed). How can I know when someone clicked that link "Unsubscribe" that appears next to the company name? Thank you.

Jaime Montoya
  • 6,915
  • 14
  • 67
  • 103
  • 1
    Look into the `List-Unsubscribe` header. It'll tell Gmail where to ping about the unsubscribe. https://help.returnpath.com/hc/en-us/articles/222445307-What-is-the-List-Unsubscribe-header- – ceejayoz Apr 15 '20 at 21:02
  • @ceejayoz I found this link even more detailed: https://sendgrid.com/blog/list-unsubscribe/. Yes, `List-Unsubscribe` was what I needed. Please write your comment as an answer so that I can mark this question as answered. – Jaime Montoya Apr 15 '20 at 22:49

1 Answers1

1

The header "List-unsubscribe links" can take a setting on how you want to inform you:

1) a mail to When a recipient click the "list-unsubscribe", this automatically generates an email notifying the sender that an email address has unsubscribed. The unsubscribe header is set up with the email address that will receive the unsubscribe requests.

2) an unsubscribe URL A link that will take the subscriber to your page to process the unsubscribe request. At your page you can ask the user to confirm the unsubscribe or the reason for statistis.

example (using both type of setting)

From: weeklynews@example.com
Subject: News about tech
Date: April 15, 2020
To: myhappycleint@somecompany.com
List-Unsubscribe:<mailto:unscubscribe@example.com>, <https://example.com/unsubscribes.php>

Beware because not all mail clients support URL:

Gmail: Mailto, URL
Outlook: Mailto
Yahoo: Mailto
Thunderbird: Mailto, URL
iOS mail: Mailto