mirror of
https://github.com/python/cpython.git
synced 2024-12-04 07:15:09 +08:00
49fd7fa443
number of tests, all because of the codecs/_multibytecodecs issue described here (it's not a Py3K issue, just something Py3K discovers): http://mail.python.org/pipermail/python-dev/2006-April/064051.html Hye-Shik Chang promised to look for a fix, so no need to fix it here. The tests that are expected to break are: test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecs test_multibytecodec This merge fixes an actual test failure (test_weakref) in this branch, though, so I believe merging is the right thing to do anyway.
33 lines
916 B
Python
33 lines
916 B
Python
# Import smtplib for the actual sending function
|
|
import smtplib
|
|
|
|
# Here are the email package modules we'll need
|
|
from email.mime.image import MIMEImage
|
|
from email.mime.multipart import MIMEMultipart
|
|
|
|
COMMASPACE = ', '
|
|
|
|
# Create the container (outer) email message.
|
|
msg = MIMEMultipart()
|
|
msg['Subject'] = 'Our family reunion'
|
|
# me == the sender's email address
|
|
# family = the list of all recipients' email addresses
|
|
msg['From'] = me
|
|
msg['To'] = COMMASPACE.join(family)
|
|
msg.preamble = 'Our family reunion'
|
|
|
|
# Assume we know that the image files are all in PNG format
|
|
for file in pngfiles:
|
|
# Open the files in binary mode. Let the MIMEImage class automatically
|
|
# guess the specific image type.
|
|
fp = open(file, 'rb')
|
|
img = MIMEImage(fp.read())
|
|
fp.close()
|
|
msg.attach(img)
|
|
|
|
# Send the email via our own SMTP server.
|
|
s = smtplib.SMTP()
|
|
s.connect()
|
|
s.sendmail(me, family, msg.as_string())
|
|
s.close()
|