Created
January 7, 2014 19:28
-
-
Save hinnerk/8305312 to your computer and use it in GitHub Desktop.
Get mail exchange provider for a list of domains.
This file contains 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
#!/usr/bin/env python2.6 | |
import commands | |
domains = ['meine-domain.de', 'meine-andere-domain.com'] | |
def slice_domain(o): | |
ergebnis = "UNDEFINED" | |
count = 0 | |
for line in o.split("\n"): | |
if not line.startswith(";") and "mx" in line: | |
count += 1 | |
ergebnis = line.split(" ")[-1] | |
if domain in ergebnis: | |
ergebnis = "EIGEN" | |
if count > 1: | |
ergebnis = "%s (multiple: %s)" % (ergebnis, count) | |
return ergebnis | |
for domain in domains: | |
s, o = commands.getstatusoutput("dig -t MX %s" % domain) | |
o = o.lower() | |
if s != 0: | |
ergebnis = "ERROR" | |
elif "google" in o: | |
ergebnis = "Google Apps" | |
elif "kundenserver" in o: | |
ergebnis = "1&1" | |
elif "ispgateway.de" in o: | |
ergebnis = "FOURTY SIX Media GmbH" | |
else: | |
ergebnis = slice_domain(o) | |
print "%s:\t%s" % (domain, ergebnis) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment