mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-04 03:32:27 +00:00
python-3.6.zip added from Github
README.cosmo contains the necessary links.
This commit is contained in:
parent
75fc601ff5
commit
0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions
29
third_party/python/Doc/includes/email-mime.py
vendored
Normal file
29
third_party/python/Doc/includes/email-mime.py
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Import smtplib for the actual sending function
|
||||
import smtplib
|
||||
|
||||
# And imghdr to find the types of our images
|
||||
import imghdr
|
||||
|
||||
# Here are the email package modules we'll need
|
||||
from 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 addresses
|
||||
msg['From'] = me
|
||||
msg['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)
|
Loading…
Add table
Add a link
Reference in a new issue