mailgun 到电子邮件地址替换为抄送电子邮件地址
mailgun to email address replaced by cc email address
我在发送带有 cc 参数的电子邮件时遇到 mailgun 问题。
但是当我执行该方法时,我从抄送电子邮件中收到了错误的 header。
这是我的代码
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)
所以,谁能帮我解决这个问题?
这是从电子邮件发送给
的信息
这是我从cc邮箱收到的
嗯,我无法重现你的问题。我在地址正确的收件人和抄送邮箱中收到相同的邮件消息。这是来自 cc 邮箱的屏幕:
要继续解决问题,请您执行以下操作:
使用调用 netgun API 时使用的确切代码更新您的问题。
这里的小事很重要,我们应该了解是什么让你和我的电话有所不同。
您能否也更新您的问题,将原始邮件消息发送到抄送邮箱。在 gmail 中,您可以通过单击回复按钮附近的向下箭头并选择 "Show original":
来完成此操作
邮件中会有一堆不同的headers包括to和cc:
请与我们分享您收到的整个邮件包。
- 如果可能,请检查邮件地址不在 gmail 上的问题。它对我来说在 gmail 上工作正常,但在你的情况下可能是邮件修改的根本原因。
请在您的代码中添加一个request.Method = Method.POST;
,因为
根据 official C# mailgun api documentation.
你能试试这个代码吗(使用相同的顺序):
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);
此致
您好,我似乎无法复制您的问题,但是,每当我使用 mailgun 时,我都会使用以下代码,它对我来说工作正常。如果你想试试这个。
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);
}
然后简单地用
调用它
ResponseModel.SendSimpleMessage(email);
编辑:我在您的代码中看到的唯一问题是它缺少
request.Method = Method.POST;
POST方法定义如下"POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server"
希望对您有所帮助
我在发送带有 cc 参数的电子邮件时遇到 mailgun 问题。 但是当我执行该方法时,我从抄送电子邮件中收到了错误的 header。
这是我的代码
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)
所以,谁能帮我解决这个问题?
这是从电子邮件发送给
的信息这是我从cc邮箱收到的
嗯,我无法重现你的问题。我在地址正确的收件人和抄送邮箱中收到相同的邮件消息。这是来自 cc 邮箱的屏幕:
要继续解决问题,请您执行以下操作:
使用调用 netgun API 时使用的确切代码更新您的问题。 这里的小事很重要,我们应该了解是什么让你和我的电话有所不同。
您能否也更新您的问题,将原始邮件消息发送到抄送邮箱。在 gmail 中,您可以通过单击回复按钮附近的向下箭头并选择 "Show original":
来完成此操作
邮件中会有一堆不同的headers包括to和cc:
请与我们分享您收到的整个邮件包。
- 如果可能,请检查邮件地址不在 gmail 上的问题。它对我来说在 gmail 上工作正常,但在你的情况下可能是邮件修改的根本原因。
请在您的代码中添加一个request.Method = Method.POST;
,因为
根据 official C# mailgun api documentation.
你能试试这个代码吗(使用相同的顺序):
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);
此致
您好,我似乎无法复制您的问题,但是,每当我使用 mailgun 时,我都会使用以下代码,它对我来说工作正常。如果你想试试这个。
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);
}
然后简单地用
调用它ResponseModel.SendSimpleMessage(email);
编辑:我在您的代码中看到的唯一问题是它缺少
request.Method = Method.POST;
POST方法定义如下"POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server"
希望对您有所帮助