This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bmispelon
Recipients bmispelon, docs@python
Date 2015-02-24.15:15:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The first code example at throws an `AttributeError` because `MIMEText`'s constructor expects a `str` object, not a `bytes` one:

>>> # Import smtplib for the actual sending function
... import smtplib
>>> # Import the email modules we'll need
... 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(
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/lib/python3.4/email/mime/", line 33, in __init__
AttributeError: 'bytes' object has no attribute 'encode'
Date User Action Args
2015-02-24 15:15:02bmispelonsetrecipients: + bmispelon, docs@python
2015-02-24 15:15:02bmispelonsetmessageid: <>
2015-02-24 15:15:02bmispelonlinkissue23511 messages
2015-02-24 15:15:02bmispeloncreate