The following fails with an error message about not being able to encode the euro char. It works fine without the €.

I have the feeling I'm missing something simple here, but can't figure it out. A fix would be appreciated.

I'd like to use this in 2.5.4 and 3.1

import smtplib
from email.mime.text import MIMEText

sender = to = 'ABC@DEF.com'
server = 'smtp.DEF.com'

msg = MIMEText('€10')
msg['Subject'] = 'Hello'
msg['From'] = sender
msg['To'] = to

s = smtplib.SMTP(server)
s.sendmail(sender, [to], msg.as_string())
s.quit()

Any suggestions or pointers for search? There are a large number of smtplib examples out there, but everything I find either (1) assumes plaintext and ignores encoding issues or (2) encodes attachments, but not in ways that generate readable characters (e.g., change everything to base64).

See if Unicode Emails in Python does anything to solve the problem.

It looks to me like you are reuqired to set the mime encoding to tell it you are using Unicode

I already tried his code. Fails in 3.1