Last active
          July 17, 2021 01:47 
        
      - 
      
- 
        Save daniel12fsp/42bb9ad798a25944f48562c911916b2e to your computer and use it in GitHub Desktop. 
    Detect if domain can receive email
  
        
  
    
      This file contains hidden or 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 { Resolver } = require('dns'); | |
| function domainHasSupportToReceiveEmail(domain) { | |
| const resolver = new Resolver(); | |
| resolver.setServers(['8.8.8.8']); | |
| return new Promise((resolve, reject) => { | |
| resolver.resolveMx(domain, (err, address) => { | |
| console.log(address) | |
| if (err) return reject(err) | |
| if(address.length ===0) return resolve(false) | |
| resolve(true) | |
| }); | |
| }) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment