Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import sys
- import telnetlib
- #print 'email:<%s> n' % str(sys.argv[1])
- if len(sys.argv) == 1:
- print "ERROR:tYou must provide an email address you wish to validate."
- sys.exit(1)
- rcpt = 'rcpt to:<%s>n' % str(sys.argv[1])
- print rcpt
- domain = str(sys.argv[1]).split('@')[1]
- print domain
- server = (subprocess.check_output(['dig', '+short', domain,'MX'])).split('n')
- print 'Server:<%s>n' % server
- server.pop()
- server.sort()
- print 'Server[0]:<%s>n' % server[0]
- server = (server[0]).split(' ')[1].rsplit('.', 1)[0]
- print 'Server after spliting:<%s>n' % server
- #============================[ TELNET SESSION ]=================================
- telnet = telnetlib.Telnet(server, "25")
- telnet.write('ehlo computer.comn')
- telnet.write('mail from:<otto@earth.org>n')
- telnet.write(rcpt)
- telnet.write('quitn')
- #print 'rcpt final:<%s>n' % rcpt
- return_code = (telnet.read_all().split('n')[-3]).split(' ')[0]
- #print 'return_code:<%s>n' % return_code
- if return_code != '250':
- #print '%r is *NOT* a valid recipient on %s' % (str(sys.argv[1]), domain)
- sys.exit(2)
- else:
- print str(sys.argv[1])
- sys.exit(0)
- carathas@aol.com
- 029@aol.com
- 08norcal2pl@aol.com
- 08norcascott@aol.com
- 08normanb@aol.com
- 0gt@aol.com
- 1-nov@aol.com
- 1.finofear534@aol.com
- while read in;
- do
- ./verify-email.py "$in";
- done < /home/itstym/Desktop/email_database/sample.txt
- >cpt to:<carathas@aol.com
- instead of this
- rcpt to:<carathas@aol.com
Add Comment
Please, Sign In to add comment