def get_mx_domains(domain, dns_resolver=_dns_resolver):
 mx_records = []
 try:
  mx_records = dns_resolver().query(domain, 'MX')
 except NoNameservers:
  log.error('NoMXservers', domain=domain)
 except NXDOMAIN:
  log.error('No such domain', domain=domain)
 except Timeout:
  log.error('Time out during resolution', domain=domain)
  raise
 except NoAnswer:
  log.error('No answer from provider', domain=domain)
  mx_records = _fallback_get_mx_domains(domain)
 return [str(rdata.exchange).lower() for rdata in mx_records]

def get_mx_domains ( domain , dns_resolver = _dns_resolver ) : mx_records = [ ] try : mx_records = dns_resolver ( ) . query ( domain , 'MX' ) except NoNameservers : log . error ( 'NoMXservers' , domain = domain ) except NXDOMAIN : log . error ( 'No such domain' , domain = domain ) except Timeout : log . error ( 'Time out during resolution' , domain = domain ) raise except NoAnswer : log . error ( 'No answer from provider' , domain = domain ) mx_records = _fallback_get_mx_domains ( domain ) return [ str ( rdata . exchange ) . lower ( ) for rdata in mx_records ]
retrieve and return the mx records for a domain .