Your startup's service is on servers in the cloud, your SMTP service is sitting over on the Mandrill servers.
You send out emails, they bounce, people click things, they want to unsubscribe, etc. – they have to call back some API endpoints.
We've already covered what's need to process unsubscribe events:
You use webhooks:
The webhook request:
* always uses the same data format, regardless of the event type.
* is a standard POST request
* with a single parameter - mandrill_events.
* containing JSON.
Don't have a working example to show, but use the following snippets as starting points.
string mandrillEventsAsJson = System.Web.HttpContext.Current.Request.Params["mandrill_events"];
Whether you have to Decode it first is to be seen.
Then process it:
void Main()
{
string jsonData =
@"[
{""ts"":123,
""event"":""send"",
""url"":""http://foo.com"",
""user_agent"":""bar"",
""environment"":""bar"",
""location"":[
{
""country_short"": ""en"",
""country_long"": ""en"",
""region"": ""en"",
""city"": ""en""
}
],
}
]
";
var r = JsonConvert.DeserializeObject<List<RootObject>>(jsonData);
r[0].url.Dump();
}
// Define other methods and classes here
public class Location
{
public string country_short { get; set; }
public string country_long { get; set; }
public string region { get; set; }
public string city { get; set; }
}
public class RootObject
{
public int ts { get; set; }
public string @event { get; set; }
public string url { get; set; }
public string user_agent { get; set; }
public string environment { get; set; }
public List<Location> location { get; set; }
}
Depending on the event value, update a database.
senddeferralhard_bouncesoft_bounceopenclickspamunsubreject
Customer.EmailAddressIsValid=false; etc.
Make sure to respond with an OK.