Created
June 10, 2018 07:31
-
-
Save miguelmota/0aac245b79f69f8a3f6e4bd7fa389e96 to your computer and use it in GitHub Desktop.
Node.js check if domain has MX DNS records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dns = require('dns') | |
function hasMxRecords(domain) { | |
return new Promise((resolve, reject) => { | |
dns.resolveMx(domain, (err, addresses) => { | |
if (err) return reject(err) | |
resolve(addresses && !!addresses.length) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment