I am developing an Asp.Net application, where I am sending a mail to the user's email address, if he forgets the password.
I want to check if the mail has been sent sucessfully or not. Is there any method to know that for sure.
EDIT
In case if an email id does'nt exists, then would I detect a failure.
if your SmtpMail.Send(message)
method returns no error, it means the email was sent to the SMTP server, then you are out of your jurisdiction, that is how far you can know.
Put the .Send(msg) method in a try catch block, and catch SmtpFailedRecipientException.
try
{
mail.Send(msg);
}
catch (SmtpFailedRecipientException ex)
{
// ex.FailedRecipient and ex.GetBaseException() should give you enough info.
}
If you're using System.Net.Mail try out
message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnSuccess;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With