SSL:WRONG_VERSION_NUMBER]错误的版本号

时间:2018-04-12 04:32:16

标签: python ssl smtplib

我正在尝试将电子邮件轰炸机作为我的python任务的一部分。

import smtplib
import ssl
from threading import Thread
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText

fromaddr = "xxx"
toaddr = "yyy"
server = smtplib.SMTP('smtp.gmail.com', 587)
context = ssl.SSLContext(ssl.PROTOCOL_SSLv3)
server.ehlo()
server.starttls()
server.ehlo()
server.login("xxx", "yyy")

def make_msg():
    msg = MIMEMultipart()
    msg['From'] = fromaddr
    msg['To'] = toaddr
    msg['Subject'] = "Python email"

    body = "Python test mail"
    msg.attach(MIMEText(body, 'plain'))

    return msg

def send_mail(msg):
    text = msg.as_string()
    server.sendmail(fromaddr, toaddr, text)


def main():
    #fromaddr = raw_input("Enter your e-mail: ")
    #toaddr = raw_input("Enter the e-mail to bomb: ")
    no_of_threads = input("Enter the number of Threads: ")
    threads = []
    #make_server_ready()

    for i in range(10):
        msg = make_msg()
        t = Thread(target=send_mail, args=(msg, ))
        threads.append(t)
        t.start()

    for i in range(10):
        threads[i].join()


if __name__ == "__main__":
    main()

它给了我以下错误: SMTPServerDisconnected:连接意外关闭:[SSL:WRONG_VERSION_NUMBER]版本号错误(_ssl.c:1858)

请帮助!!

0 个答案:

没有答案