· 8 years ago · Mar 28, 2018, 10:20 AM
1import sys
2import subprocess
3import re
4
5_map = {
6 '.gmail.com.': 'Gmail',
7 '.aspmx.l.google.com.': 'G Suite',
8 '.mail.protection.outlook.com.': 'Office 365',
9 '.mail.eo.outlook.com.': 'Office 365',
10 '.emailsrvr.com.': 'RSE/HEX',
11 '.secureserver.net.': 'GoDaddy',
12}
13
14if __name__ == '__main__':
15 for l in sys.stdin:
16 e = l.strip ().lower ()
17 d = e.split ('@').pop ()
18
19 o = subprocess.check_output ('dig +short mx %s' % (d), shell = True)
20 if o == '':
21 print ('N/A')
22 else:
23 o = ';'.join (o.split ('\n')).lower ()
24 p = None
25 if d in o:
26 p = 'Self-Hosted/CNAME'
27 else:
28 for x in _map.keys ():
29 if re.search (x, o):
30 p = _map.get (x)
31 break
32
33 print (p or 'Other')