How to check if an email has been sent successfully?

Asked

Viewed 3,207 times

4

I am trying to verify if an email sent from my application is successfully sent, wanting to know if the recipient receives it or not (full mailbox, invalid email, around). From what I’ve researched there is deliverynotificationoptions that the match should give me information whether the email was sent or not.

mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Delay;

Then I try to send the email:

try
{
   SmtpCliente.Send(mail);
}
catch (Exception ex)
{
   return ex.Message;
}

The truth is I’m not getting that information... Is there another way to get this information, or is it really impossible?

  • Hello. A detail, the DeliveryNotificationOptions are flags. why to use them should do .OnFailure | .OnSuccess | .Delay.

1 answer

3


After the execution of the method SmtpCliente.Send(mail);, If no exceptions occur, this means that the email was sent to the SMTP server. After that, there is no guarantee that your email will be delivered to the recipient. See this link that stackoverflow in English.

Note that even the event message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnSuccess; does not guarantee that your message will be received as the recipient may not send you a reply email and have received your message.

  • But even if I use an invented email (like [email protected]), it never fails to execute the SmtpCliente.Send(mail); In the Try catch I have, it never enters the catch in case the email is invented

  • 1

    The SMTP protocol unfortunately does not verify if its recipient exists. I understand your frustration, since unfortunately you can guarantee very little in relation to the sending of emails.

  • I am using Mailjet to send, and I can always check the status of the email by the browser... But I see I can’t get that data by code

  • Note that Mailjet has an API that allows calling functions via REST: https://www.mailjet.com/docs/api

  • 1

    The following link shows a method for retrieving a list of outgoing emails. Even so, there is no guarantee that they have been received. https://www.mailjet.com/docs/api/report/emailsent

  • Exactly, pity to be in php :/ I’ll see if I can replicate the code to C#

  • Despite being in PHP, you can make REST calls in C#. However, I agree that it would be simpler if the API was in C#.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.