Api 使用SendGrid邮件枪跟踪电子邮件
我正在学习一些电子邮件服务,如sendgrid和MailGun 在MailGun文档中,我发现了一个非常有用的函数: 您可以简单地向MailgunAPI请求触发的事件,并发送一些过滤器。它非常简单和强大。这里有一个例子:Api 使用SendGrid邮件枪跟踪电子邮件,api,events,sendgrid,webhooks,mailgun,Api,Events,Sendgrid,Webhooks,Mailgun,我正在学习一些电子邮件服务,如sendgrid和MailGun 在MailGun文档中,我发现了一个非常有用的函数: 您可以简单地向MailgunAPI请求触发的事件,并发送一些过滤器。它非常简单和强大。这里有一个例子: using System; using System.IO; using RestSharp; using RestSharp.Authenticators; public class EventsDateTimeRecipientChunk { public st
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..."
}
}
{
“项目”:[
{
“标签”:[],
“时间戳”:1376325780.160809,
“信封”:{
“发件人”:me@samples.mailgun.org",
“传输”:”
},
“事件”:“已接受”,
“活动”:[…],
“用户变量”:{},
“旗帜”:{
“已验证”:正确,
“is测试模式”:false
},
“信息”:{
“标题”:{
“至”:user@example.com",
“消息id”:“20130812164300.28108。52546@samples.mailgun.org",
“发件人”:“兴奋用户”,
“主题”:“你好”
},
“附件”:[],
“收件人”:[
"user@example.com"
],
“尺寸”:69
},
“收件人”:user@example.com",
“方法”:“http”
}
],
“分页”:{
“下一步”:
"https://api.mailgun.net/v3/samples.mailgun.org/events/W3siY...",
“以前的”:
"https://api.mailgun.net/v3/samples.mailgun.org/events/Lkawm..."
}
}
是否可能在SendGrid中找不到相同的功能?我正在疯狂地搜索他们的文件。。我找到了网络钩子,但这不是我需要的。我只想像MailGun一样通过http请求查看电子邮件状态
你能帮我吗?希望你现在已经明白了 然而,对于未来: 您应该使用Webhook,如下所示: 1.配置应用程序:单击Track、opentrack和。您想要做什么eventnotify为true,使用Get&activate 2使用RequestPin创建姿势 3在dashboard中激活邮件设置中的事件通知,并检查所需的事件,当您按下testYourIntegration按钮时,您应该会收到对所创建url的示例post请求
from_email=电子邮件(“..”) 主题=“…” 内容=内容(“文本/普通”、“尝试发送网格”) 邮件=邮件(从电子邮件、主题、到电子邮件、内容) response=sg.client.mail.send.post(request\u body=mail.get()) 现在,打开或单击“代码”发送的电子邮件,取消对事件的锁定,然后返回(&O)
https://requestb.in/api/v1/bins/bin_id/requests
使用代码执行Get请求&只需解析JSON即可