api - Tracking email with SendGrid alike MailGun -


i'm studying email services, sensdgrid , mailgun.

in mailgun docs found usefull function: https://documentation.mailgun.com/user_manual.html#events

you can ask mailgun api events triggered, sending filters. simple , powerful. here example:

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

and output sample:

{   "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..."   } } 

is possible can't find same feature in sendgrid? i'm getting crazy searching in documents.. found webhooks, isn't need. want see email status http request mailgun does.

can me?

hope figured out now,

yet here's future : should use webhooks, follows:

1 configure apps: clicktrack, opentrack& .what_you_want_to_tarck.. & eventnotify true, & activate

2 create posturl using requestpin,

3 activate event notification mail settings in dashboard & check events want , when press testyourintegration button, should example post request created url.

  1. use code described in official documentation:

    string apikey = "......." sg = sendgrid.sendgridapiclient(apikey=os.environ.get( apikey )) to_email = email("....@gmail.com")
    from_email =email ("....") subject= '...' content = content("text/plain","trying sendgrid") mail = mail(from_email, subject, to_email, content) response = sg.client.mail.send.post(request_body=mail.get())

    now , go & open or click email sent code, declench event .., go

    https://requestb.in/your_bin_id?inspect

& should see notifications after little while

for more, can go :

https://requestb.in/api/v1/bins/bin_id/requests 

do request code & parse json


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -