Python sends mail using smtplib library and smtp.qq.com mail server

Source: Internet
Author: User

The two places to be aware of when using QQ mail server are:

1. Protocol issues using the 465-Port SSL protocol

2. Password problem occurs smtpauthenticationerror main reason is the password and account information is not correct, here we use QQ server send need to set up a separate password in the mailbox (must), and then open

SMTP/POP3 Services. Then with the QQ Mobile Security Center sweep will give an authorization code, in the code to fill in the password is this authorization code , not the mailbox password!

Here's a code:

 

#Coding:utf8From SmtplibImportSmtp_sslFrom Email.headerImportHeaderFrom Email.mime.textImportMimetextmail_info ={"From":"xxxx@qq. com","To":"XXX@qq. com","Hostname":"Smtp.qq.com","Username":"XXX@qq. com","Password":"Xxx","Mail_subject":"Test","Mail_text":"Hello, this was a test email, sended by py","Mail_encoding":"Utf-8"}If__name__ = =‘__main__‘:#Using Smtp_ssl here is the default use of port 465 SMTP = SMTP_SSL (mail_info["Hostname"]) Smtp.set_debuglevel (1) Smtp.ehlo (mail_info["Hostname"]) Smtp.login (mail_info["Username"], mail_info["Password"]) msg = Mimetext (mail_info["Mail_text"],"Plain", mail_info["Mail_encoding"]) msg["Subject"] = Header (mail_info["Mail_subject"], mail_info["Mail_encoding "" from "] = Mail_info["  From " Msg[" to "] = Mail_info[ to< Span style= "color: #800000;" > " Smtp.sendmail (Mail_info[" fromto "", msg.as_string ()) smtp.quit ()    

The Debian System OS command gnome-screenshot-a the custom area files in the picture folder in the HOME directory.

Http://www.cnblogs.com/inva/p/5115794.html

Python sends mail using smtplib library and smtp.qq.com Mail server (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.