0 votes

We need to determine whether the email address being used to send the email message to exists or not.

I assume I should use Limilabs.Mail.Tools.AddressValidator, but I am always getting a NoMXRecord AddressValidationResult.

Can you please provide me with sample code on how validate whether the email address exists/is valid? Thank you.

by

1 Answer

0 votes

NoMXRecord means that there is no MX record for the domain of the
provided email address.

There are 3 AddressValidator methods you can use to validate email address:

  • ValidateFormat - Validates email address format only.
  • ValidateMX - Validates email address format and the existence of MX record.
  • Validate - Validates email address format, existence of MX record, and SMTP connection.

We need to determine whether the email address being used to send the email message to exists or not.

My question is why?

There is no 100% reliable way of detecting, if email address is valid.

Before attempting to send you should validate format only (validation of MX record
existence is as far as you should go).

Then simply send a message:
you'll either get a SMTP error if your SMTP server immediately rejects the address,
-or- a bounce if there is a failure at some later stage.

Consider using VERP to easily process bounces:
https://www.limilabs.com/blog/verp-variable-envelope-return-path-net

by (297k points)
...