Today, I saw the Marco Linux operation in the public number, pushed an article, using Python to send mail cases, so the experiment, success, speed record.
Using the python3.x version, install the Zmail module;
Pip Install Zmail
This time use QQ mailbox to send mail, the premise is need to open QQ mailbox POP3/SMTP function;
After opening, the QQ number will be asked to apply for a second-generation password protection, and then the next step, if successful, will generate a grant password right;
Note: Be sure to remember this authorization code, usually need to use QQ mailbox involved in the case of code, most will use this authorization code;
For example: My authorization code is: Nnddlbwwuusrieie
Once the prerequisites are configured, the code is left: zmail_test.py file
Import Zmail
Mail_content = {
' Subject ': ' Zmail send mail successj ', #标题随意写
' Content ': ' This message from Zmail ', #邮件内容, feel free to write
}
Server = Zmail. MailServer ('* * *[email protected] ', ' Nnddlbwwuusrieie ') #此处需要的是发送者的邮箱和授权码
Server.send_mail (' 1*****[email protected] ', mail_content) #此处是目的邮箱地址和邮件内容
Print (' OK ')
Run:
Python zmail_test.py
After sending, can go to 1*****[email protected] mailbox to check the contents can;
Send mail using Python's Zmail module