0

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()
2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by foosion
0

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).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.