Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mailgun to email address replaced by cc email address

Tags:

c#

mailgun

I have an issue with mailgun when send an email with cc param. But when I execute the method, I have got wrong header from cc email.

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 protected]");
request.AddParameter("cc", "[email protected]");
client.Execute(request)

So, Can anyone please help me to resolve this?

This is information from email to

enter image description here

This is what I get from cc Email

enter image description here

like image 877
Luc Nguyen Avatar asked Feb 01 '18 03:02

Luc Nguyen


People also ask

Does Mailgun save emails?

Storing Messages through Routes You can store messages temporarily (up to 3 days) by creating a store() action using Routes.

Is Mailgun an email provider?

Mailgun is a leading provider of email API services you can use to send, validate, and receive emails through your domain at scale. It also lets you track the performance of your sent emails with robust open, click, bounce, and delivery tracking.

How do I add authorized recipients in Mailgun?

Select your sandbox domain from among the domains list; you'll see the name as a long string starting with "sandbox." On the right-hand side of the resulting page, you will see a tile that allows you to enter a new or view an existing Authorized Recipient.

How many emails can I send using Mailgun?

There is a limit of 300 messages per day on the included sandbox domain. Data retention for Logs and the Events API is 1 day. You cannot create custom domains. You can only send to Authorized Recipients; and there is a maximum of 5 Authorized Recipients.


2 Answers

Hm, I can't reproduce your problem. I'm getting the same mail message in both to and cc mailboxes with correct addresses. Here is a screen from cc mailbox:

enter image description here

To proceed with the problem, could you please do the following:

  1. Update your question with the exact code you use for calling netgun API. Little things matter here and we should understand what makes difference between your and my calls.

  2. Could you also please update your question with raw mail message got to cc mailbox. In gmail you could do it by clicking down arrow near reply button and selecting "Show original":

enter image description here

There will be a bunch of different headers in the message including to and cc:

enter image description here

Please share with us the whole mail packet you get.

  1. If possible, please check the issue with mail address not on gmail. It works ok for me on gmail but may be in your case it's the root cause of message modification.
like image 188
CodeFuller Avatar answered Oct 27 '22 18:10

CodeFuller


Please add a request.Method = Method.POST; in your code, because according to official C# mailgun api documentation.

Could you try this code (with the same order) :

    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 protected]>");
    request.AddParameter ("to", "[email protected]");
    request.AddParameter ("cc", "[email protected]");
    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);

Regards

like image 20
A STEFANI Avatar answered Oct 27 '22 17:10

A STEFANI