mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	svn+ssh://pythondev@svn.python.org/python/trunk ........ r71874 | jeroen.ruigrok | 2009-04-25 13:59:09 +0200 (za, 25 apr 2009) | 2 lines First attempt to document PyObject_HEAD_INIT and PyVarObject_HEAD_INIT. ........ r71882 | jeroen.ruigrok | 2009-04-25 14:49:10 +0200 (za, 25 apr 2009) | 3 lines Issue #4239: adjust email examples not to use connect() and terminate with quit() and not close(). ........ r71890 | jeroen.ruigrok | 2009-04-25 15:07:40 +0200 (za, 25 apr 2009) | 3 lines Rewrite a sentence to be more in line with the rest of the documentation with regard to person and audience. ........
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			903 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			903 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.sendmail(me, family, msg.as_string())
 | 
						|
s.quit()
 |