Christoph Haas skrev: > Hello, everyone... > > I'm trying to send an email to people with non-ASCII characters in their > names. A recpient's address may look like: > > "Jörg Nørgens" <[EMAIL PROTECTED]> > > My example code: > > ================================= > def sendmail(sender, recipient, body, subject): > message = MIMEText(body) > message['Subject'] = Header(subject, 'iso-8859-1') > message['From'] = Header(sender, 'iso-8859-1') > message['To'] = Header(recipient, 'iso-8859-1') > > s = smtplib.SMTP() > s.connect() > s.sendmail(sender, recipient, message.as_string()) > s.close() > ================================= > > However the Header() method encodes the whole expression in ISO-8859-1: > > =?iso-8859-1?q?=22J=C3=B6rg_N=C3=B8rgens=22_=3Cjoerg=40nowhere=3E?= > > However I had expected something like: > > "=?utf-8?q?J=C3=B6rg?= =?utf-8?q?_N=C3=B8rgens?=" <[EMAIL PROTECTED]> > > Of course my mail transfer agent is not happy with the first string
Why offcourse? But it seems that you are passing the Header object a utf-8 encoded string, not a latin-1 encoded. You are telling the header the encoding. Not asking it to encode. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list