In some simple cases your SMTP server will inform you that the recipient address is wrong immediately. Those cases include:
- wrong email format.
- non-existent email address that is in the same domain (hosted on the same server)
You will get such error in ISendMessageResult
object returned by Smtp.SendMessage
method.
In many other cases your SMTP doesn't know if the address is valid or not. It needs to start trying to deliver your message - technically it needs to connect to the recipient's SMTP server first
(this of course happens some time after your (Mail.dll's) interaction with your SMTP server finished).
If the recipient's server doesn't exist (e.g. mailbox@no-such-domain.com) -or- email address is not correct (e.g. no-such-mailbox@gmail.com) error is raised, bounce message is generated and is send back to you.
Such messages are called Delivery Status Notification or DSNs for short.
You can use Imap
component to receive such error messages, you can use Bounce
class to recognize and parse them:
https://www.limilabs.com/blog/bounce-handling
a very good idea is to use VERP:
https://www.limilabs.com/blog/verp-variable-envelope-return-path-net