Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created June 10, 2018 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/0aac245b79f69f8a3f6e4bd7fa389e96 to your computer and use it in GitHub Desktop.
Save miguelmota/0aac245b79f69f8a3f6e4bd7fa389e96 to your computer and use it in GitHub Desktop.
Node.js check if domain has MX DNS records
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