S
S
Saharman2018-10-05 11:44:53
ASP.NET
Saharman, 2018-10-05 11:44:53

Why is the email not being sent using the Mailgun API?

Trying to send email using MailGun API

public IRestResponse SendMessage()
        {
            RestClient client = new RestClient();
            client.BaseUrl = new Uri("https://api.mailgun.net/v3");
            client.Authenticator =
                new HttpBasicAuthenticator("api",
                                            "my-api-key");
            RestRequest request = new RestRequest();
            request.AddParameter("domain", "abc.ru", ParameterType.UrlSegment);
            request.Resource = "{domain}/messages";
            request.AddParameter("from", "Excited User <[email protected]>");
            request.AddParameter("to", "[email protected]");
            request.AddParameter("subject", "Hello");
            request.AddParameter("text", "Testing some Mailgun awesomness!");
            request.Method = Method.POST;
            return client.Execute(request);
        }

I get the following JSON in response
{
  "request": null,
  "contentType": null,
  "contentLength": 0,
  "contentEncoding": null,
  "content": "",
  "statusCode": 0,
  "isSuccessful": false,
  "statusDescription": null,
  "rawBytes": null,
  "responseUri": null,
  "server": null,
  "cookies": [
    
  ],
  "headers": [
    
  ],
  "responseStatus": 2,
  "errorMessage": "Operation is not supported on this platform.",
  "errorException": {
    "ClassName": "System.PlatformNotSupportedException",
    "Message": "Operation is not supported on this platform.",
    "Data": null,
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": "   at System.Net.SystemWebProxy.GetProxy(Uri destination)\r\n   at System.Net.ServicePointManager.ProxyAddressIfNecessary(Uri& address, IWebProxy proxy)\r\n   at System.Net.ServicePointManager.FindServicePoint(Uri address, IWebProxy proxy)\r\n   at System.Net.HttpWebRequest.get_ServicePoint()\r\n   at RestSharp.Http.ConfigureWebRequest(String method, Uri url)\r\n   at RestSharp.Http.PostPutInternal(String method)\r\n   at RestSharp.Http.AsPost(String httpMethod)\r\n   at RestSharp.RestClient.DoExecuteAsPost(IHttp http, String method)\r\n   at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func`3 getResponse)",
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": null,
    "HResult": -2146233031,
    "Source": "System.Net.Requests",
    "WatsonBuckets": null
  },
  "protocolVersion": null
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question