How to check if the mail has been sent successfull

2019-02-01 21:03发布

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.

8条回答
迷人小祖宗
2楼-- · 2019-02-01 22:04

You can use the DeliveryNotificationOptions to receive a receipt.

If you have a MailMessage object named mail, do this:

mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
查看更多
太酷不给撩
3楼-- · 2019-02-01 22:05

The SmtpClient.Send method will raise an Exception if there's a problem sending. But beyond getting that message to the SMTP server, there's no way to know if it makes it to the destination from there.

查看更多
登录 后发表回答