[New-bugs-announce] [issue15763] email non-ASCII characters in TO or FROM field doesn't work

Helmut Jarausch report at bugs.python.org
Wed Aug 22 13:28:08 CEST 2012


New submission from Helmut Jarausch:

Trying to generate an email with Latin-1 characters in the TO or FROM
field either produces an exception or produces strange values in the generated email:

Using  Python 3.2.3+ (3.2:481f5d9ef577+, Aug  8 2012, 10:00:28) 


#!/usr/bin/python3
#-*- coding: latin1 -*-

import smtplib
from email.message import Message
import datetime
import sys

msg= Message()
msg.set_charset('latin-1')
msg['Subject'] = "*** Email Test ***"

# the following gives a  UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc ..
# in File "/usr/lib64/python3.2/email/header.py", line 281, in append
# msg['From'] = FromAddr = "Günter Groß <Email_Tester at numa-sv.igpm.rwth-aachen.de>".encode('iso-8859-1')


# The following doesn't crash Python but generates a strange "From" string :
# =?utf-8?b?R8O8bnRlciBHcm/DnyA8RW1haWxfVGVzdGVyQG51bWEtc3YuaWdwbS5yd3RoLWFhY2hlbi5kZT4=?=

msg['From'] = FromAddr = "Günter Groß <Email_Tester at numa-sv.igpm.rwth-aachen.de>"


# The same with this one
msg['To']   = ToAddr   = "Günter Weiße <jarausch at igpm.rwth-aachen.de>"

DATE = datetime.datetime.utcnow().strftime('%m/%d/%Y %I:%M:%S %p')
msg['Date'] = datetime.datetime.utcnow().strftime('%m/%d/%Y %I:%M:%S %p')

server= smtplib.SMTP("igpm.igpm.rwth-aachen.de")
# server= smtplib.SMTP('relay.skynet.be')
server.set_debuglevel(9)

msg.set_payload("Gedanken über einen Test","iso-8859-1")
# server.send_message(msg)
server.sendmail(FromAddr,ToAddr,msg.as_string().encode("iso-8859-1"))
server.quit()

----------
components: email
messages: 168869
nosy: HWJ, barry, r.david.murray
priority: normal
severity: normal
status: open
title: email  non-ASCII characters in TO or FROM field doesn't work
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15763>
_______________________________________


More information about the New-bugs-announce mailing list