简体   繁体   English

邮件地址已被cc电子邮件地址替换为电子邮件地址

[英]mailgun to email address replaced by cc email address

I have an issue with mailgun when send an email with cc param. 发送带有cc param的电子邮件时,我遇到了mailgun的问题。 But when I execute the method, I have got wrong header from cc email. 但是当我执行该方法时,我从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 please help me to resolve this? 那么,任何人都可以帮我解决这个问题吗?

This is information from email to 这是来自电子邮件的信息

在此输入图像描述

This is what I get from cc Email 这是我从cc Email获得的

在此输入图像描述

Hm, I can't reproduce your problem. 嗯,我无法重现你的问题。 I'm getting the same mail message in both to and cc mailboxes with correct addresses. 我在具有正确地址的to和cc邮箱中收到相同的邮件消息。 Here is a screen from cc mailbox: 这是cc邮箱的屏幕:

在此输入图像描述

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. 使用您用于调用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. 您也可以通过原始邮件消息更新您的问题到cc邮箱。 In gmail you could do it by clicking down arrow near reply button and selecting "Show original": 在Gmail中,您可以通过单击“回复”按钮旁边的箭头并选择“显示原始文件”来执行此操作:

在此输入图像描述

There will be a bunch of different headers in the message including to and cc: 消息中会有一堆不同的标题,包括to和cc:

在此输入图像描述

Please share with us the whole mail packet you get. 请与我们分享您获得的整个邮件包。

  1. If possible, please check the issue with mail address not on gmail. 如果可能,请检查邮件地址不在Gmail上的问题。 It works ok for me on gmail but may be in your case it's the root cause of message modification. 它在gmail上对我有效,但在你的情况下它可能是消息修改的根本原因。

Please add a request.Method = Method.POST; 请添加request.Method = Method.POST; in your code, because according to official C# mailgun api documentation . 在你的代码中,因为根据官方C#mailgun api文档

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.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);

Regards 问候

Hi I cant seem to replicate your problem however, whenever i use mailgun i use the following code and it works fine for me. 嗨,我似乎无法复制你的问题,但是,每当我使用mailgun我使用以下代码,它对我来说工作正常。 if you want to give this a 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 simply call it with 然后简单地用它来调用它

ResponseModel.SendSimpleMessage(email);

EDIT: the only issue i can see in your code is that it is lacking 编辑:我能在你的代码中看到的唯一问题是它缺乏

request.Method = Method.POST;

POST Methods are defined as the following "POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server" POST方法定义如下:“POST方法用于将实体提交到指定的资源,通常会导致服务器上的状态或副作用发生变化”

I hope this helps 我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM