Send mail using Python's Zmail module

Source: Internet
Author: User
Tags password protection
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

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.