Can I know with SendGrid if an email arrives or does not reach its recipient when I send it?

1
        var client = new SendGridClient(this.apiKey);

        var from = new EmailAddress(_from);
        var subject = _subject;
        var to = new EmailAddress(_to);
        var plainTextContent = _plainTextContent;
        var htmlContent = _htmlContent;
        var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
        var response = client.SendEmailAsync(msg);

I send the email using the SendGrid library with c #. Can the library be used so that once it is sent, a response is obtained if the mail arrives or something happens (there is no mail)?

PS: The question of whether it is in the SendGrid list does not work for me, I need it once I send the email and I do not make two requests to consult that list.

    
asked by Marck Vit 18.09.2018 в 19:30
source

2 answers

2

Yes you can but not directly from your sending, they report the events to you by a POST, that is, you must create an EndPoint that receives that POST, right there on your page they have a button where you put your URL and you can try a example that they send you.

link

This is the json that you are sent as an example where the type of event comes

[{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "processed",
    "category": "cat facts",
    "sg_event_id": "ZVi3_VSzK015oIYdynYgEQ==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "deferred",
    "category": "cat facts",
    "sg_event_id": "fDoij-hAjVx8xOQvh2gb3A==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "response": "400 try again later",
    "attempt": "5"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "delivered",
    "category": "cat facts",
    "sg_event_id": "aoIheLGPJOrEobVrCo3L8g==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "response": "250 OK"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "open",
    "category": "cat facts",
    "sg_event_id": "y6zxWDMzNKpe2fcVLZ1K7A==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "useragent": "Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
    "ip": "255.255.255.255"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "click",
    "category": "cat facts",
    "sg_event_id": "wdMAd5gRmmQJxYEP7HN1fw==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "useragent": "Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
    "ip": "255.255.255.255",
    "url": "http://www.sendgrid.com/"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "bounce",
    "category": "cat facts",
    "sg_event_id": "Lr8M9TpuvKBn7lWQllHeZg==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "reason": "500 unknown recipient",
    "status": "5.0.0"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "dropped",
    "category": "cat facts",
    "sg_event_id": "sqZZ6dpAZ_3voL0_v2BQkg==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "reason": "Bounced Address",
    "status": "5.0.0"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "spamreport",
    "category": "cat facts",
    "sg_event_id": "QP8bGoU0HzNZd0XnVMw0VQ==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "unsubscribe",
    "category": "cat facts",
    "sg_event_id": "mNHkKKWQfwnTMpCuByNwqg==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0"
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "group_unsubscribe",
    "category": "cat facts",
    "sg_event_id": "2QSHciT_oAuL_qh2eg2cKw==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "useragent": "Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
    "ip": "255.255.255.255",
    "url": "http://www.sendgrid.com/",
    "asm_group_id": 10
},
{
    "email": "[email protected]",
    "timestamp": 1529499943,
    "smtp-id": "u003c14c5d75ce93.dfd.64b469@ismtpd-555u003e",
    "event": "group_resubscribe",
    "category": "cat facts",
    "sg_event_id": "pWf-D5yw3or_ZuWMxQuZkQ==",
    "sg_message_id": "14c5d75ce93.dfd.64b469.filter0001.16648.5515E0B88.0",
    "useragent": "Mozilla/4.0 (compatible; MSIE 6.1; Windows XP; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
    "ip": "255.255.255.255",
    "url": "http://www.sendgrid.com/",
    "asm_group_id": 10
}]
    
answered by 18.09.2018 в 20:20
1

I'm afraid you can not since the service is based on SMTP

The most approximate thing you can do is send a link in the email that the user receives so that when you press it, enter a page that you develop and launch the validation process of the reception of the mail

This is used a lot in registry validations

To do this you should host a website where you develop a page that you send in the mail, it could be something like

http:\sitio\RecepticionMail?token=xxx

next to the url you should put an encrypted token that you receive and you can recover the data of the user who received the mail

    
answered by 18.09.2018 в 19:45