mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #23511: Port email-simple.py to Python 3.
Also, update email examples to use the context manager version of open(). Patch by Baptiste Mispelon.
This commit is contained in:
parent
b808d590a2
commit
f9e3cf1f9f
4 changed files with 10 additions and 10 deletions
|
@ -6,10 +6,9 @@ from email.mime.text import MIMEText
|
|||
|
||||
# Open a plain text file for reading. For this example, assume that
|
||||
# the text file contains only ASCII characters.
|
||||
fp = open(textfile, 'rb')
|
||||
# Create a text/plain message
|
||||
msg = MIMEText(fp.read())
|
||||
fp.close()
|
||||
with open(textfile) as fp:
|
||||
# Create a text/plain message
|
||||
msg = MIMEText(fp.read())
|
||||
|
||||
# me == the sender's email address
|
||||
# you == the recipient's email address
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue