In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people are at a loss about how to realize the function of automatically sending and receiving email in Python. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Project environment
Language: Python
Editor: Pycharm
Libraries: smtplib, email
Code analysis
Let's first set up the sending account and receiving account of the email. As variables, I use the QQ account here, and the sender is my second account.
My_sender = 'xxxx@qq.com' # sender's email account
My_user = 'xxxx@qq.com' # recipient email account
Basic Information Settin
Next, we set up some basic information about the mailbox and login operations. The sent text is processed into Chinese encoding using the MIMEText method. Set information such as the subject of the message and the sender of the message.
Log in to the mailbox
Login mailbox we need to define the mail transfer protocol, the general mail transfer protocol is SMTP,QQ mailbox is smtp.qq.com, NetEase mailbox is smtp.qq.com, other mailboxes can be checked on the Internet. The port defaults to 25. Log in to the mailbox with the login method, the first parameter is the login account, and the second parameter note that the password here is not the login password of the mailbox, but the authorization code of the mailbox, which can be viewed in the mailbox settings. The following is QQ Mail's viewing method. Other mailbox viewing methods are similar.
After the login is successful, use the sendmail method to send the email, and then exit the email.
Finally, enter the title and content parameters of sending mail, and then call the function to realize the function of sending and receiving mail.
Mail_title = 'report'
Mail_content = 'report content'
SendMail (mail_title, mail_content)
After reading the above, have you mastered the method of how to automatically send and receive email in Python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
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.