it:ad:mandrill:howto:configure_unsubscription

IT:AD:Mandrill:HowTo:Configure Unsubscription

Summary

Before you blindly put it on everything, are you sure you need an unsubscribe link on your email?

See: IT:BD:Marketing/Transactional Email/Legal

With transactional email, Mandrill is not keeping a list of your clients – it's up to your website to add/remove the target email address so that future emails are not sent to that address.

Before you get started, you need to provide an API endpoint that Mandrill can call back to, that you can process, and unsubscribe the customer.

As per the documentation (http://help.mandrill.com/entries/23815367-Can-I-add-an-automatic-unsubscribe-link-to-Mandrill-emails-)

The endpoint needs to process two querystrings parameters :

  • 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

In other words, the url invoked will look like:

http://mywebsite.com/api/unsub?md_id=xyz?md_email

Just process the md_email:

string emailAddressToUnsubscribe = Server.UrlDecode(Request.QueryString["md_email"]);

Mandrill provides a Tag to use …but I'm not keen on it at all due to impacting your reputation score.

MailMessage mailMsg = new MailMessage();

mailMsg.Headers.Add("X-MC-MergeVars","{\"var1\": \"SomeVar\",\"msgType\":\"Foo\"}");

mailMsg.To.Add(new MailAddress("skysigal@xact-solutions.com", "Sky Sigal"));
mailMsg.From = new MailAddress("skysigal@xact-solutions.com", "Test");
mailMsg.Subject = "subject *|VAR1|*";

string text = "text body *|VAR1|*";
string html =
@"<p>html <b>body</b><p>Your order *|VAR1|*.</p>
<p><a href=""*|UNSUB:http://mywebsite.com/api/unsub|*"">Click here to unsubscribe.</a></p>
<p><a href=""*|UNSUB:http://mywebsite.com/api/unsub/*|MSGTYPE|*|*"">Click here to unsubscribe.</a></p>
";
mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(text, null,
																	   MediaTypeNames.Text.Plain));
mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, Encoding.UTF8,
																	   MediaTypeNames.Text.Html));
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMsg);

Will produce:


<p>
<!-- notice that it posts back to Mandrill, which impacts your Reputation, before it sends it on to the url you mentioned -->
<a href="http://mandrillapp.com/track/click.php?u=30142762&id=904e3693c31e4873b0c93689efb279ef&url=http%3A%2F%2Fmandrillapp.com%2Ftrack%2Funsub.php%3Fu%3D30142762%26id%3D904e3693c31e4873b0c93689efb279ef.YaWaEcsEmO5gHv%252FGOb3deg08vQs%253D%26r%3Dhttp%253A%252F%252Fmywebsite.com%252Fapi%252Funsub%253Fmd_email%253Dskysigal%252540xact-solutions.com&url_id=87f923f18286fc97800a5707ea202c3a04500fa4">Click here to unsubscribe.</a>
</p>

<!-- Could not parse the nested tags -->
<p>
<a href="*|UNSUB:http://mywebsite.com/api/unsub/Foo|*">Click here to unsubscribe.</a>
</p>

  • /home/skysigal/public_html/data/pages/it/ad/mandrill/howto/configure_unsubscription.txt
  • Last modified: 2023/11/04 01:48
  • by 127.0.0.1