def sendmail():
    try:
        import smtplib
        from email.mime.text import MIMEText
        from email.utils import formataddr

        msg = MIMEText('你猜我是谁,你猜你不猜,我猜你会猜','plain','utf-8')
        msg['From'] = formataddr(["小俊男","******@126.com"])
        msg['To'] = formataddr(["亲爱的你",'[email protected]'])
        msg['Subject'] = "万圣节快乐"

        server = smtplib.SMTP("smtp.126.com",25)
        server.login("********@126.com","登录密码")
        server.sendmail("******@126.com",['收信邮箱@qq.com',],msg.as_string())
        server.quit()
    except:
        return "111"
    else:
        return "222"
        
for i in range (18):

    retuxn_i = sendmail()
    print(retuxn_i)
    if retuxn_i == '111':
        print("发送失败")
    else:
        print("发送成功")