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 airween
Recipients airween
Date 2015-11-26.07:46:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1448523992.32.0.105956858988.issue25736@psf.upfronthosting.co.za>
In-reply-to
Content
Looks like smtplib can send only messages, which contains only 7bit (ascii) characters. Here is the example:

# -*- coding: utf8 -*-

import time
import smtplib

mailfrom = "my@mydomain.com"
rcptto = "me@otherdomain.com"

msg = """%s
From: Me <%s>
To: %s
Subject: Plain text e-mail
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

happy New Year

Ευτυχισμένο το Νέο Έτος

明けましておめでとうございます

с Новым годом
""" % (time.strftime('%a, %d %b %Y %H:%M:%S +0100', time.localtime()), mailfrom, rcptto)

server = smtplib.SMTP('localhost')
server.sendmail(mailfrom, rcptto, msg)
server.quit()


With Python2 (Python 2.7), this script finished succesfully. With Python3 (Python 3.4), I've got this execption:

Traceback (most recent call last):
  File "8bittest.py", line 28, in <module>
    server.sendmail(mailfrom, rcptto, msg)
  File "/usr/lib/python3.4/smtplib.py", line 765, in sendmail
    msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 261-271: ordinal not in range(128)


Basicly, I don't understand, why smtplib allows only ascii encoded messages in Python 3. That worked (and works) in Python 2, and I think, that's the correct behavior.
History
Date User Action Args
2015-11-26 07:46:32airweensetrecipients: + airween
2015-11-26 07:46:32airweensetmessageid: <1448523992.32.0.105956858988.issue25736@psf.upfronthosting.co.za>
2015-11-26 07:46:32airweenlinkissue25736 messages
2015-11-26 07:46:30airweencreate