Mailgun replaced with email address cc

I have a problem with mailgun when sending email using cc param. But when I execute the method, I have the wrong email header from cc.

This is my code.

var client = new RestClient
{
    BaseUrl = new Uri("https://api.mailgun.net/v3"),
    Authenticator = new HttpBasicAuthenticator("api", "secret-key")
};

var request = new RestRequest();
request.AddParameter("to", "email.to@gmail.com");
request.AddParameter("cc", "email.cc@gmail.com");
client.Execute(request)

So can anyone help me solve this problem?

This is information from email to

enter image description here

This is what I get from cc Email

enter image description here

+4
source share
3 answers

Hm, I cannot reproduce your problem. I get the same mail message in both mailboxes and with mailboxes with the correct addresses. Here is the screen from the cc mailbox:

enter image description here

To fix the problem, could you do the following:

  • , API netgun. , , .

  • , cc. gmail , " ":

enter image description here

, to cc:

enter image description here

, .

  1. , , gmail. gmail, .
+5

request.Method = Method.POST; , # mailgun api.

( ):

    RestClient client = new RestClient ();
    client.BaseUrl = new Uri ("https://api.mailgun.net/v3");
    client.Authenticator =
        new HttpBasicAuthenticator ("api",
                                    "YOUR_API_KEY");
    RestRequest request = new RestRequest ();
    request.AddParameter ("domain", "YOUR_DOMAIN_NAME", ParameterType.UrlSegment);
    request.Resource = "{domain}/messages";
    request.AddParameter ("from", "Email From <email.from@gmail.com>");
    request.AddParameter ("to", "email.to@gmail.com");
    request.AddParameter ("cc", "email.cc@gmail.com");
    request.AddParameter ("subject", "Email Subject");
    request.AddParameter ("text", "Testing some Mailgun awesomness!");
    request.AddParameter ("o:tracking", false);
    request.Method = Method.POST;
    return client.Execute (request);

+2

Hi, I cannot reproduce your problem, however, when I use mailgun I use the following code and it works fine for me. if you want to try.

public static IRestResponse SendSimpleMessage(string email)
    {
        var order = new CustomerOrder();
        RestClient client = new RestClient();
        client.BaseUrl = new Uri("https://api.mailgun.net/v3");
        client.Authenticator =
                new HttpBasicAuthenticator("api",
                                           "key-MINE");
        RestRequest request = new RestRequest();
        request.AddParameter("domain",
                             "DOMAINHERE.mailgun.org", ParameterType.UrlSegment);
        request.Resource = "{domain}/messages";
        request.AddParameter("from", "Shop Staff <postmaster@EMAILTHING>");
        request.AddParameter("to", email);
    request.AddParameter("cc", "Shop Staff <insert email here>");
        request.AddParameter("subject", "Your Order has been placed");
        request.AddParameter("text", "Thank you for placing an order with our shop, we have just begun processing your order. You will recieve a follow up email when your order is ready for collection");
        request.Method = Method.POST;
        return client.Execute(request);
    }

and then just call him

ResponseModel.SendSimpleMessage(email);

EDIT: the only problem I see in your code is the lack

request.Method = Method.POST;

POST methods are defined as follows: "The POST method is used to send an entity to a specified resource, often causing a change in state or side effects on the server"

I hope this helps

0
source

Source: https://habr.com/ru/post/1693008/


All Articles