Mail-Address Check
Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Version vom 16. Dezember 2015, 02:46 Uhr von Sigi (Diskussion | Beiträge) (Die Seite wurde neu angelegt: «<syntaxhighlight lang="python"> #!/usr/bin/python # Copyright (c) 2015 by Peter_Siegrist(SystemLoesungen) (PSS @ ZweierNet.ch) # pss.ZweierNet.ch # # All Right…»)
#!/usr/bin/python # Copyright (c) 2015 by Peter_Siegrist(SystemLoesungen) (PSS @ ZweierNet.ch) # pss.ZweierNet.ch # # All Rights reserved. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # from socket import * import sys import string if len(sys.argv) < 4: print 'usage: ', sys.argv[0], ' ' sys.exit(False) server = sys.argv[1] port = int(sys.argv[2]) mail_to_check = sys.argv[3] sSocket = socket(AF_INET, SOCK_STREAM) sSocket.connect((server, port)) recv = sSocket.recv(1024) #print recv sSocket.send('HELO xy\r\n') recv2 = sSocket.recv(1024) #print recv2 sSocket.send('RSET\r\n') recv1 = sSocket.recv(1024) #print recv1 sSocket.send('MAIL FROM: addrecheck@example.org\r\n') recv3 = sSocket.recv(1024) #print recv3 sSocket.send('RCPT TO: ' + mail_to_check + '\r\n') recv4 = sSocket.recv(1024) #print recv4 recv5 = recv4.replace("\n", "").replace("\r", "") if recv5[-2:] == 'ok' or recv5[-2:] == 'OK': sys.exit(True) sys.exit(False)