好吧,我的反应有点奇怪
我正在另一个文件上执行以下文件。
验证电子邮件.sh (来源)
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)
我有包含电子邮件列表的文件(sample.txt):
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
我正在运行 Unix 脚本,该脚本将逐行处理 example.txt 并对其运行 ./verify-email.sh 。
while read in;
do
./verify-email.py "$in";
done < /home/itstym/Desktop/email_database/sample.txt
但我得到了回声(第 7 行)
>cpt to:<[email protected]
instead of this
rcpt to:<[email protected]