Send QQ mail via python
# Encoding = UTF-8 _ author _ = 'ds' # File Name Conflict from email. mime. text import MIMETextimport smtplibif _ name _ = '_ main _': msg = MIMEText (_ text = 'smtp test', _ charset = 'utf-8 ') # enter the Email address and password from_addr = 'xxx @ qq.com 'password = 'xxx' # enter the SMTP server address: smtp_server = 'smtp .qq.com' # enter the recipient address: to_addr = 'xxx @ sina.cn '# The default SMTP port is 25 server = smtplib. SMTP (smtp_server, 25) server. set_debuglevel (1) # server. starttls () # server. connect (host = smtp_server, port = 25) # server. esmtp_features ["auth"] = "AUTH_LOGIN" server. login (from_addr, password) server. sendmail (from_addr, [to_addr], msg. as_string () server. quit ()
After the test, the error 454 is reported. It turns out that the SMTP service of the email is disabled in the QQ mailbox, and external access is unavailable.
Open the QQ mail account-> account security, and open the SMTP service and POP3 service.