POP3 Mailchecker (with custom server list)
Soo hier ein POP3 Checker denn ich schon vor geraumer Zeit zusammengehackt habe, der aber noch prima funktioniert.
Die Maildaten sollten entsprechendes Format haben:
Code:
test@gmx.de:passwort
wobei der Delimiter (Doppelpunkt) auch ein anderer Buchstabe sein kann, wenn dies entsprechend beim Programmaufruf spezifiziert wurde.
Usage
Code:
[17:18:48] s3rb31@archbase:~/code/mailchecker $ ./mailchecker.py
Usage:
./mailchecker.py -i <inputfile> [-d <delim>] [-s <srv-list>]
<delim> defaults to ':'
<srv-list> defaults to 'popdata.txt'
Use the '>' operator to redirect the output to any given file,
for example:
./mailchecker.py -i inputfile.txt -s srvlst.txt > C:\data\outputfile.txt
mailchecker.py
Code:
#!/usr/bin/python
# written by s3rb31@mail.ru
# don't steal my code! don't leak!
import zlib
import poplib
import sys, time
import re, getopt
class POP3Checker():
def __init__(self, input_file, srv_file, delim):
self.srv_list = []
for line in open(srv_file, "r"):
self.srv_list.append(line.rstrip('\r\n'))
if len(self.srv_list) < 1:
raise EOFError("Error: Server list is empty!")
self.input_list = []
for line in open(input_file, "r"):
self.input_list.append(line.rstrip('\r\n'))
if len(self.input_list) < 1:
raise EOFError("Error: E-Mail list is empty!")
self.delim = delim
def __get_srv__(self, mail):
mail_host = mail.split('@')[1]
for i in range(0, len(self.srv_list)):
srv = self.srv_list[i]
srv_host_end = srv.find('(')
if srv_host_end == -1 or srv[0:1] != '@':
print("Error on line " + str(i+1) + " in server list.\n" +
"Server information is malformed, skipping entry.")
del self.srv_list[i]; continue
if mail_host == srv[1:srv_host_end]:
return srv[srv_host_end + 1:-1].split(':')
return False
def __check_login__(self, mail, pw, srv):
while True:
try:
conn = poplib.POP3_SSL(srv[0], srv[1]) if srv[1] == "995" else poplib.POP3(srv[0], srv[1])
conn.user(mail)
conn.pass_(pw)
conn.quit()
return True
except poplib.error_proto:
if '@' in mail:
mail = mail.split('@')[0]
continue
break
except OSError as e:
print("Error: " + e.strerror + " Server: " + srv[0] + ":" + srv[1])
break
return False
def __parse_line_and_check__(self, line):
pw = line.split(self.delim, 1)[1]
mail = line.split(self.delim, 1)[0]
srv = self.__get_srv__(mail)
if srv == False:
return 'NOSERVER'
return 'SUCCESS' if self.__check_login__(mail, pw, srv) else 'FAIL'
def start(self):
for line in self.input_list:
if len(line) > 3:
status = self.__parse_line_and_check__(line)
print(line + self.delim + status) # this is our final output
def usage(name):
help_str = "Usage:\n\t"
help_str += name + " -i <inputfile> [-d <delim>] [-s <srv-list>]\n\n"
help_str += " <delim> defaults to ':'\n"
help_str += " <srv-list> defaults to 'popdata.txt'\n\n"
help_str += " Use the '>' operator to redirect the output to any given file,\n"
help_str += " for example:\n\n\t"
help_str += name + " -i inputfile.txt -s srvlst.txt > C:\data\outputfile.txt"
print(help_str)
if __name__ == "__main__":
delim = ':'
input_file = ''
srv_file = 'popdata.txt'
try:
opts, args = getopt.getopt(sys.argv[1:], "hi:d:s:")
except getopt.GetoptError:
usage(sys.argv[0]);
sys.exit()
for opt, arg in opts:
if opt in ("-i"): input_file = arg
elif opt in ("-d"): delim = arg[0:1]
elif opt in ("-s"): srv_file = arg
if len(input_file) < 1 or len(srv_file) < 1 or len(delim) < 1:
usage(sys.argv[0]);
sys.exit()
try:
checker = POP3Checker(input_file, srv_file, delim)
checker.start()
except FileNotFoundError as e:
print("Error: " + e.strerror + " '"+ e.filename + "'")
except EOFError as e:
print(str(e))
popdata.txt
Code:
@12move.de(pop.12move.de:110)
@addcom.de(pop.addcom.de:110)
@alice.de(pop3.alice.de:110)
@aol.com(pop.aol.com:110)
@aol.de(pop.aol.com:995)
@arcor.de(pop3.arcor.de:110)
@compuserve.de(pop.compuserve.de:110)
@directbox.com(pop3.directbox.com:995)
@directbox.de(pop3.directbox.com:995)
@email.de(pop3.web.de:995)
@epost.de(mail.epost.de:110)
@freenet.de(mx.freenet.de:995)
@gmail.com(pop.gmail.com:995)
@gmx.ch(pop.gmx.net:995)
@gmx.at(pop.gmx.net:995)
@gmx.de(pop.gmx.net:995)
@gmx.info(pop.gmx.net:995)
@gmx.com(pop.gmx.net:995)
@gmx.org(pop.gmx.net:995)
@gmx.net(pop.gmx.net:995)
@googlemail.com(pop.gmail.com:995)
@hotmail.de(pop-mail.outlook.com:995)
@hotmail.com(pop-mail.outlook.com:995)
@hushmail.com(pop.hushmail.com:110)
@kabelmail.de(pop3.kabelmail.de:110)
@live.com(pop-mail.outlook.com:995)
@live.de(pop-mail.outlook.com:995)
@lycos.de(pop.lycos.de:110)
@mail.de(pop.mail.de:995)
@msn.com(pop-mail.outlook.com:995)
@msn.de(pop-mail.outlook.com:995)
@ok.de(mail.ok.de:110)
@online.de(pop.1und1.de:110)
@onlinehome.de(pop.onlinehome.de:110)
@1und1.de(pop.onlinehome.de:110)
@outlook.com(pop-mail.outlook.com:995)
@outlook.de(pop-mail.outlook.com:995)
@planet-interkom.de(pop.planet-interkom.de:110)
@space2go.com(pop.space2go.com:110)
@strato.de(pop3.strato.de:110)
@surfeu.de(pop.surfeu.de:110)
@t-online.de(popmail.t-online.de:110)
@tiscali.de(pop.tiscali.de:110)
@versanet.de(pop3.versatel.de:110)
@web.de(pop3.web.de:995)
@worldonline.de(pop.worldonline.de:110)
@yahoo.com(pop.mail.yahoo.com:110)
@yahoo.com(pop.mail.yahoo.com:995)
@yahoo.de(pop.mail.yahoo.com:995)
@yahoo.de(pop.mail.yahoo.de:110)
@yahoo.net(pop.mail.yahoo.com:995)
@ymail.com(pop.mail.yahoo.com:995)
@me.com(mail.me.com:110)
@mail.ru(pop.mail.ru:110)
Man kann die Liste mit den POP Server natürlich beliebig erweitern. Falls jemand da noch Listen hat darf er die auch gerne Posten!
AW: POP3 Mailchecker (with custom server list)
Kleiner Verbesserungsvorschlag: Wenn Anbieter nicht in der Liste evtl standard subdomains/ports probieren.
Ansonsten sieht das Script nicht schlecht aus.
AW: POP3 Mailchecker (with custom server list)
Erstmal Danke fürs Feedback und schön das es gefällt.
Zitat:
Zitat von
schteal
jo sehe ich ähnlich. vlt. gibts ja auch ne möglichkeit da bei thunderbird via api die serverinfos abzugreifen o.Ä. ?
Wie meinst du dass?
AW: POP3 Mailchecker (with custom server list)
Bei Thunderbird wird dir, wenn du ein Konto hinzufügst automatisch die subdomain/der port erkannt.
AW: POP3 Mailchecker (with custom server list)
Tatsächlich hat Mozilla schon ganze Arbeit geleistet.
Code:
https://svn.mozilla.org/mozillamessaging.com/sites/autoconfig.mozillamessaging.com/trunk/
Edit: Es gibt auch Code um selbst eine Datenbank zu verwalten wenn ich das richtig gesehen hab. Evtl. überführe ich das ganze mal in SQLite3 (so scheint Mozilla das auch zu usen), dann kann man mit Python einfach die Domainendung extrahieren und via SQLite3 den passenden Server abfragen.
Momentan hab ich leider alle Hände voll zu tun, also wenn sich jemand berufen fühlt: nur zu.
AW: POP3 Mailchecker (with custom server list)
aber auch bei unbekannten domains werden die standard-dinge probiert.
smtp.domain
pop3.domain
pop.domain
imap.domain
und dann halt die passendne ports 993,995,110,143,25,465