One: The advantages of Zmail:
1: Auto-populate most of the headers that cause server-side rejects (From To LocalHost and the like)
2: Mapping a dictionary to email, constructing a letter is as simple as constructing a dictionary
3: Automatically find the mail service provider port number address, automatically select the appropriate protocol (certified)
4: depends only on python3, no need to worry when embedding other projects
II: Install zmail
pip install zmail
III: Using zmail
1: Send mail
import zmail mail_content = { 'subject':'Success',# Theme 'content':'This is a content',#Mail Content } #Which mailbox to use to send emails server = ('243681093@','tkccftyagtkobghh') # Which email to send to server.send_mail('wangjian@',mail_content)
Attention:
Use the mailbox to send mail need to open SMTP service, the following qq mailbox as an example to open SMTP
First login qq mailbox, click settings to enter account settings
Enable POP3/STMP and IMAP/SMTP.
When qq mailbox is used as the sender, the second parameter is to enable IMAP/SMTP 16-digit secret key instead of password, it will report an error if password is used, but when other mailboxes are used as the sender, it will be successful if password is used.
2: Add attachments to your emails, modify the content of your emails that is, and other content as above.
mail_content = { 'subject': 'Success!', # Theme 'content': 'This message from zmail!', #Mail Content 'attachments': '/Users/zyh/Documents/', # Attachment contents (it is best to use the absolute path, if your computer does not have this file will cause an error) }
3: send mail to multiple mailboxes, modify the send mail that is, the other contents of the same as above
# Send mail server.send_mail(['555555@','666666@'], mail_content)
Above is python using zmail library to send mail details, more information about python send mail please pay attention to my other related articles!