Mail-Address Check: Unterschied zwischen den Versionen
Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
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…») |
Sigi (Diskussion | Beiträge) |
||
Zeile 50: | Zeile 50: | ||
recv5 = recv4.replace("\n", "").replace("\r", "") | recv5 = recv4.replace("\n", "").replace("\r", "") | ||
− | if recv5[-2:] == 'ok | + | if recv5[-2:].lower() == 'ok': |
sys.exit(True) | sys.exit(True) | ||
sys.exit(False) | sys.exit(False) |
Version vom 16. Dezember 2015, 14:33 Uhr
#!/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:].lower() == 'ok': sys.exit(True) sys.exit(False)