public void Send(IMessage message, string emailAddress) { Guard.StringIsNullOrEmpty(emailAddress, "EmailAddress"); var key = ConfigurationManager.AppSettings["MAILGUN_API_KEY"]; RestClient client = new RestClient(); client.BaseUrl = "https://api.mailgun.net/v2"; client.Authenticator = new HttpBasicAuthenticator("api", key); RestRequest request = new RestRequest(); request.AddParameter("domain", "app11515.mailgun.org", ParameterType.UrlSegment); request.Resource = "app11515.mailgun.org/messages"; request.AddParameter("from", "Tweedehandsmeldingen <*****@*****.**>"); request.AddParameter("to", emailAddress); request.AddParameter("subject", message.RenderTitle()); request.AddParameter(message.Type, message.RenderBody()); request.Method = Method.POST; var response = client.Execute(request); if (response.ErrorException != null) throw response.ErrorException; }