Node JS Email Validation with MX DNS Record Check

Typically we do the email validation with regular expression which will validate the structure. The Regular expression can be useless even after it is validated the format if the domain does not exist.

So validating with regular expression is not enough, sometime you may required to validate even more low-level. For any domain MX record are responsible for delivering email to recipient address. So we gonna validate MX record for the provided email address domain with Node Js’s build-in dns module.

The Code

The Usage

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets. Protection Status