In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 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: 0
*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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.