-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigmx.py
28 lines (23 loc) · 826 Bytes
/
digmx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
"""Resolving """
import dns.resolver
import dns.exception
def getmxrecords():
"""Purpose to get the mx records through dnspython module"""
with open('transport_domains.txt', 'r') as domains:
for row in domains:
try:
answers = dns.resolver.query(row.rstrip(), 'MX')
for rdata in answers:
print ('Domain', row.strip(), 'Host', rdata.exchange,
'has preference', rdata.preference)
except dns.resolver.NXDOMAIN:
continue
except dns.resolver.NoNameservers:
continue
except dns.exception.Timeout:
continue
except dns.resolver.NoAnswer:
continue
if __name__ == '__main__':
getmxrecords()