You can try it and use it to send an email after the error
#!/usr/bin/env Python3
#-*-Coding:utf-8-*-
From Email.header Import Header
From Email.mime.text import Mimetextimport smtplib
#username = "[Email protected]"
Password = "Authorization Code"
#授权码在QQ邮箱设置-Open under Account
FROM_ADDR = "[Email protected]"
TO_ADDR = "[Email protected]"
Smtp_server = "Smtp.qq.com"
msg = Mimetext (' Hello, send by Python ... ', ' plain ', ' utf-8 ')
msg[' from ' = Header ("Ppyy", ' Utf-8 ')
msg[' to ' = Header ("You", ' Utf-8 ')
msg[' Subject ' = Header (' Greetings from SMTP ... ', ' utf-8 ')
Try
Server = Smtplib. Smtp_ssl (smtp_server,465)
Change #如果不是Qq smtp.qq.com to localhost
Server.login (from_addr, password)
Server.sendmail (From_addr, to_addr,msg.as_string ())
Server.quit ()
Print ("Success")
Except Smtplib. Smtpexception:
Print ("Unsuccess")
PYTHON-QQ Mailbox Send mail