Mail-Address Check: Unterschied zwischen den Versionen
Sigi (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Sigi (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 21: | Zeile 21: | ||
if len(sys.argv) < 4: | if len(sys.argv) < 4: | ||
print 'usage: ', sys.argv[0], ' | print 'usage: ', sys.argv[0], ' < mailserver-to-check-for > < port-on-server-25-or-587 > < email-adress-to-check >' | ||
sys.exit(False) | sys.exit(False) | ||
Version vom 16. Dezember 2015, 13:35 Uhr
<syntaxhighlight lang="python">
- !/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], ' < mailserver-to-check-for > < port-on-server-25-or-587 > < email-adress-to-check >' 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)