In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "python how to achieve bulk mail push and support html email format", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "python how to achieve bulk email push and support html email format" bar!
Using python to send bulk emails, promotional courses, etc., can be done with the following code:
#! / usr/bin/python#-*-coding: UTF-8-*-import smtplibfrom email.mime.text import MIMETextfrom email.header import Headerfrom email.mime.multipart import MIMEMultipartfrom email.mime.image import MIMEImage# third-party SMTP service mail_host= "smtp.exmail.qq.com" # set server mail_user= "XXXX@biomics.com.cn" # username mail_pass= "*" # password sender = 'XXXX@ Biomics.com.cn'receivers = ['XXX3@126.com' "xxx@biomics.com.cn"] # receive mail You can set it to your QQ Mail or other mailbox # create an instance with attachments msgRoot = MIMEMultipart ('related') msgRoot [' From'] = Header ("utf-8' Lecture Hall", 'utf-8') msgRoot [' To'] = Header ("Group Lecture Lecture students", 'utf-8') subject =' Python SMTP email Test 'msgRoot [' Subject'] = Header (subject) 'utf-8') msgAlternative = MIMEMultipart (' alternative') msgRoot.attach (msgAlternative) # mail_msg = "" #
Python mail delivery test.
#
Group study hall
#
Photo presentation:
#
# "" # the html format input page mail_msg = "" Tutsplus Email Newsletter a {color: # d80a3e;} body, # header H2, # header h3, p {margin: 0; padding: 0;} # main {border: 1px solid # cfcece;} img {display: block;} # top-message p, # bottom p {color: # 3f4042; font-size: 12px Font-family: Arial, Helvetica, sans-serif;} # header H2 {color: # ffffff! important; font-family: "Lucida Grande", sans-serif; font-size: 24px; margin-bottom: zero importance; padding-bottom: 0;} # header p {color: # ffffff! important; font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", sans-serif; font-size: 12px;} h6 {margin: 00 0.8em 0 } H6 {font-size: 18px; color: # 444444! important; font-family: Arial, Helvetica, sans-serif;} p {font-size: 12px; color: # 444444! important; font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", sans-serif; line-height: 1.5;}
View in Browser
Evanto Limited
November 2017
How to Get Up and Running With Vue
In the introductory post for this series we spoke a little about how web designers can benefit by using Vue. In this tutorial we'll learn how to get Vue up..
Introducing Haiku: Design and Create Motion
With motion on the rise amongst web developers so too are the tools that help to streamline its creation. Haiku is a stand-alone..
Design better experiences for web & mobile
Unsubscribe | Tweet | View in Browser
"" msgAlternative.attach (MIMEText (mail_msg, 'html',' utf-8')) # specifies that the picture is the current directory fp = open ('test.png',' rb') msgImage = MIMEImage (fp.read ()) fp.close () # defines the picture ID Reference msgImage.add_header ('Content-ID','') msgRoot.attach (msgImage) # email body content msgRoot.attach (MIMEText) in the HTML text ('this is the email delivery test sent by the assembly lecture hall …' , 'plain',' utf-8')) # construct attachment 1, and transmit the test.txt file att1 = MIMEText (open ('test.txt',' rb'). Read (), 'base64',' utf-8') att1 ["Content-Type"] = 'application/octet-stream'#' in the current directory. The filename here can be written freely, what name is written, and what name att1 ["Content-Disposition"] = 'attachment is displayed in the email. Filename= "test.txt" 'msgRoot.attach (att1) # # construct attachment 2 and transfer the runoob.txt file # att2 = MIMEText (open (' runoob.txt', 'rb'). Read (),' base64', 'utf-8') # att2 ["Content-Type"] =' application/octet-stream'# att2 ["Content-Disposition"] = 'attachment] in the current directory Filename= "runoob.txt"'# msgRoot.attach (att2) try: # smtpObj=smtplib.SMTP () # smtpObj.connect (mail_host,465) # 25 is the SMTP port number smtpObj=smtplib.SMTP_SSL (mail_host,465) # smtpObj.set_debuglevel (1) smtpObj.login (mail_user,mail_pass) smtpObj.sendmail (sender, receivers MsgRoot.as_string () print "email sent successfully" except smtplib.SMTPException: print "Error: unable to send email" Thank you for reading The above is the content of "python how to achieve batch mail push and support html mail format". After the study of this article, I believe you have a deeper understanding of how python can achieve batch mail push and support html mail format, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.