# IT:AD:Mandrill:HowTo:Configure Unsubscription #
* [[../|(UP)]]
{{indexmenu>.#2|nsort tsort}}
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.
## Process ##
### Custom API endpoint
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"]);
### Email Tags ###
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 =
@"html body
Your order *|VAR1|*.
Click here to unsubscribe.
Click here to unsubscribe.
";
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:
Click here to unsubscribe.
Click here to unsubscribe.
## Resources ##
* http://help.mandrill.com/entries/23815367-Can-I-add-an-automatic-unsubscribe-link-to-Mandrill-emails-