New submission from Ervin Hegedüs: Looks like smtplib can send only messages, which contains only 7bit (ascii) characters. Here is the example:
# -*- coding: utf8 -*- import time import smtplib mailfrom = "m...@mydomain.com" rcptto = "m...@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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25736> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com