# Import smtplib for the actual sending functionimport smtplib# And imghdr to find the types of our imagesimport imghdr# Here are the email package modules we'll needfrom email.message import EmailMessage# Create the container email message.msg = EmailMessage()msg['Subject'] = 'Our family reunion'# me == the sender's email address# family = the list of all recipients' email addressesmsg['From'] = memsg['To'] = ', '.join(family)msg.preamble = 'Our family reunion'# Open the files in binary mode. Use imghdr to figure out the# MIME subtype for each specific image.for file in pngfiles:with open(file, 'rb') as fp:img_data = fp.read()msg.add_attachment(img_data, maintype='image',subtype=imghdr.what(None, img_data))# Send the email via our own SMTP server.with smtplib.SMTP('localhost') as s:s.send_message(msg)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。