Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(30413)

Side by Side Diff: Doc/includes/email-simple.py

Issue 10321: Add support for Message objects and binary data to smtplib.sendmail
Patch Set: Created 8 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/includes/email-mime.py ('k') | Doc/library/smtplib.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Import smtplib for the actual sending function 1 # Import smtplib for the actual sending function
2 import smtplib 2 import smtplib
3 3
4 # Import the email modules we'll need 4 # Import the email modules we'll need
5 from email.mime.text import MIMEText 5 from email.mime.text import MIMEText
6 6
7 # Open a plain text file for reading. For this example, assume that 7 # Open a plain text file for reading. For this example, assume that
8 # the text file contains only ASCII characters. 8 # the text file contains only ASCII characters.
9 fp = open(textfile, 'rb') 9 fp = open(textfile, 'rb')
10 # Create a text/plain message 10 # Create a text/plain message
11 msg = MIMEText(fp.read()) 11 msg = MIMEText(fp.read())
12 fp.close() 12 fp.close()
13 13
14 # me == the sender's email address 14 # me == the sender's email address
15 # you == the recipient's email address 15 # you == the recipient's email address
16 msg['Subject'] = 'The contents of %s' % textfile 16 msg['Subject'] = 'The contents of %s' % textfile
17 msg['From'] = me 17 msg['From'] = me
18 msg['To'] = you 18 msg['To'] = you
19 19
20 # Send the message via our own SMTP server, but don't include the 20 # Send the message via our own SMTP server.
21 # envelope header.
22 s = smtplib.SMTP() 21 s = smtplib.SMTP()
23 s.sendmail(me, [you], msg.as_string()) 22 s.sendmail(msg)
24 s.quit() 23 s.quit()
OLDNEW
« no previous file with comments | « Doc/includes/email-mime.py ('k') | Doc/library/smtplib.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+