Can I add an automatic unsubscribe link to Mandrill emails?

Yes, Mandrill provides an easy-to-use merge tag to automatically add an unsubscribe link to your Mandrill emails. The merge tag consists of the word UNSUB, followed by a colon, and then a full website address (with http:// or https://) where recipients should be redirected when the unsubscribe is processed:

*|UNSUB:http://mywebsite.com/unsub|*

If a recipient clicks the generated link, the message status is changed to Unsubscribed and the recipient's address is added to the Rejection Blacklist in your Mandrill account. The redirect URL will be appended to include two query string parameters that can be used for processing the unsubscribe in your own system or database:

  • md_id: The _id, as provided in the API call and webhooks of the specific message where the unsubscribe link was clicked
  • md_email: A URL-encoded version of the recipient's email address

Using the unsub merge tag

The unsubscribe merge tag generates only the URL to unsubscribe and can be used in both HTML and text emails. In HTML, you might construct the link like this to create a clickable link for recipients to unsubscribe:

<a href="*|UNSUB:http://mywebsite.com/unsub|*">Click here to unsubscribe.</a>