Ok, estou recebendo uma resposta um pouco estranha
Estou executando o arquivo abaixo em outro arquivo.
verify-email.sh ( source )
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.com\n')
telnet.write('mail from:<[email protected]>\n')
telnet.write(rcpt)
telnet.write('quit\n')
#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)
Eu tenho o arquivo (sample.txt) que contém a lista de e-mail como:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Estou executando o script Unix que processará sample.txt linha por linha e executará ./verify-email.sh sobre isso.
while read in;
do
./verify-email.py "$in";
done < /home/itstym/Desktop/email_database/sample.txt
Mas estou recebendo o eco (linha 7)
>cpt to:<[email protected]
instead of this
rcpt to:<[email protected]