In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to send and receive email on python. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
1. Install the mail library.
Pip install PyEmail
2. For the email interface, you need to enable the mailbox configuration-SMTP service in the account.
Next, we will get the authorization code by sending SMS verification, which can be added to the code after having the authorization code.
3. Set login information, send content, etc., open smtp service and connect to the server. Log in to the mailbox to send or receive mail, and finally shut down the service.
Example
Import smtplibfrom email.mime.text import MIMETextfrom email.header import Headerimport time # sender's information: email address, QQ Mail authorization code from_addr = "xxx@qq.com" password = "xxxx" # recipient mailbox to_addr = "xxx@qq.com" # sender server smtp_server = "smtp.qq.com" # mailbox body content, the first parameter is content, and the second parameter is format (plain is plain text) The third parameter is to encode msg = MIMEText ('Robben Shuai', 'plain','utf-8') # header message msg [' From'] = Header (from_addr) msg ['To'] = Header (to_addr) msg [' Subject'] = Header ('python') # enable sending service Encrypted transmission server = smtplib.SMTP_SSL (smtp_server) server.connect (smtp_server,465) # Log in to send email server.login (from_addr,password) for i in range (2): # send email server.sendmail (from_addr,to_addr) Msg.as_string () time.sleep (1) server.quit () # shuts down the server. That's all for the article on "how to send and receive email with python". Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 267
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.