我正在学习一些电子邮件服务,比如SensdGrid和MailGun。
在MailGun文档中,我发现了一个非常有用的函数:manual.html#events
您只需向MailGun API请求触发的事件,还可以发送一些过滤器。它真的是简单而有力的。这里有一个例子:
using System;
using System.IO;
using RestSharp;
using RestSharp.Authenticators;
public class EventsDateTimeRecipientChunk
{
public static void Main (string[] args)
{
Console.WriteLine (EventsDateTimeRecipient ().Content.ToString ());
}
public static IRestResponse EventsDateTimeRecipient ()
{
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}/events";
request.AddParameter ("begin", "Fri, 3 May 2013 09:00:00 -0000");
request.AddParameter ("ascending", "yes");
request.AddParameter ("limit", 25);
request.AddParameter ("pretty", "yes");
request.AddParameter ("recipient", "joe@example.com");
return client.Execute (request);
}
}和输出样本:
{
"items": [
{
"tags": [],
"timestamp": 1376325780.160809,
"envelope": {
"sender": "me@samples.mailgun.org",
"transport": ""
},
"event": "accepted",
"campaigns": [],
"user-variables": {},
"flags": {
"is-authenticated": true,
"is-test-mode": false
},
"message": {
"headers": {
"to": "user@example.com",
"message-id": "20130812164300.28108.52546@samples.mailgun.org",
"from": "Excited User <me@samples.mailgun.org>",
"subject": "Hello"
},
"attachments": [],
"recipients": [
"user@example.com"
],
"size": 69
},
"recipient": "user@example.com",
"method": "http"
}
],
"paging": {
"next":
"https://api.mailgun.net/v3/samples.mailgun.org/events/W3siY...",
"previous":
"https://api.mailgun.net/v3/samples.mailgun.org/events/Lkawm..."
}
}我是否可能在SendGrid中找不到相同的特性呢?我在他们的文件里疯狂地搜寻..。我找到了钩子,但这不是我需要的。我只想看到与MailGun一样的http请求的电子邮件状态。
你能帮帮我吗?
发布于 2017-06-29 13:25:34
希望你现在知道了,
但是,下面是未来的情况:您应该使用webhooks,如下所示:
1配置应用程序:点击轨迹、选项和.what_you_want_to_tarck。事件通知为true,并使用Get和activate
2使用RequestPin创建POSTURL,
3从仪表板中的邮件设置中激活事件通知&检查您想要的事件,当您按下testYourIntegration按钮时,您应该将示例post请求发送到创建的url。
&您应该会在一段时间后看到通知。
要了解更多信息,您可以访问:
https://requestb.in/api/v1/bins/bin_id/requests使用代码执行Get请求&只需解析JSON
https://stackoverflow.com/questions/43271079
复制相似问题