Mail-Address Check: Unterschied zwischen den Versionen

Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Zur Navigation springen Zur Suche springen
(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…»)
 
Keine Bearbeitungszusammenfassung
Zeile 50: Zeile 50:


recv5 = recv4.replace("\n", "").replace("\r", "")
recv5 = recv4.replace("\n", "").replace("\r", "")
if recv5[-2:] == 'ok' or 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, 13:33 Uhr

<syntaxhighlight lang="python">

  1. !/usr/bin/python
  1. Copyright (c) 2015 by Peter_Siegrist(SystemLoesungen) (PSS @ ZweierNet.ch)
  2. pss.ZweierNet.ch
  3. All Rights reserved.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License as
  6. published by the Free Software Foundation.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. 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)

  1. print recv

sSocket.send('HELO xy\r\n') recv2 = sSocket.recv(1024)

  1. print recv2

sSocket.send('RSET\r\n') recv1 = sSocket.recv(1024)

  1. print recv1

sSocket.send('MAIL FROM: addrecheck@example.org\r\n') recv3 = sSocket.recv(1024)

  1. print recv3

sSocket.send('RCPT TO: ' + mail_to_check + '\r\n') recv4 = sSocket.recv(1024)

  1. print recv4

recv5 = recv4.replace("\n", "").replace("\r", "") if recv5[-2:].lower() == 'ok': sys.exit(True) sys.exit(False)