In case anyone is interested in the code I'm using... (reduced)
public bool i_sendemail_mailgun(email_object email_obj)
{
try
{
// some setup code removed from here. The variables should be self-explanatory.
RestClient client = new RestClient();
client.BaseUrl = mailgun_url;
client.Authenticator = new HttpBasicAuthenticator("api", mailgun_api_key);
RestRequest request = new RestRequest();
request.AddParameter("domain", mailgun_domain, ParameterType.UrlSegment);
request.Resource = mailgun_domain + "/" + mailgun_resource_send_message;
request.AddParameter("from", email_obj.from_addr);
request.AddParameter("to", email_obj.to_addr);
request.AddParameter("subject", email_obj.email_subj);
request.AddParameter("cc", email_obj.cc_addr);
request.AddParameter("bcc", email_obj.bcc_addr);
if (email_obj.is_html)
{
request.AddParameter("html", email_obj.email_body);
}
else
{
request.AddParameter("text", email_obj.email_body);
}
request.Method = Method.POST;
IRestResponse resp = client.Execute(request);
if (resp.StatusCode == HttpStatusCode.OK)
{
// I get this when sending the small message...
i_syslog_debug("i_sendemail_mailgun message " + email_obj.guid + " sent successfully");
return true;
}
// and I get this when sending the large message...
i_syslog_debug("i_sendemail_mailgun message " + email_obj.guid + " not sent successfully: " + resp.StatusCode + " " + resp.StatusDescription);
return false;
}
catch (Exception e_outer)
{
// never gets here...
i_exception("i_sendemail_mailgun", "exception encountered when attempting to send email", e_outer);
return false;