Emailing unicode chars?

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2009
Posts: 31
Reputation: foosion is an unknown quantity at this point 
Solved Threads: 2
foosion foosion is offline Offline
Light Poster

Emailing unicode chars?

 
0
  #1
Aug 11th, 2009
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

  1. import smtplib
  2. from email.mime.text import MIMEText
  3.  
  4. sender = to = 'ABC@DEF.com'
  5. server = 'smtp.DEF.com'
  6.  
  7. msg = MIMEText('€10')
  8. msg['Subject'] = 'Hello'
  9. msg['From'] = sender
  10. msg['To'] = to
  11.  
  12. s = smtplib.SMTP(server)
  13. s.sendmail(sender, [to], msg.as_string())
  14. s.quit()
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 31
Reputation: foosion is an unknown quantity at this point 
Solved Threads: 2
foosion foosion is offline Offline
Light Poster

Re: Emailing unicode chars?

 
0
  #2
Aug 14th, 2009
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).
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 2
Reputation: oooooops is an unknown quantity at this point 
Solved Threads: 0
oooooops oooooops is offline Offline
Newbie Poster

Re: Emailing unicode chars?

 
0
  #3
Aug 14th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 31
Reputation: foosion is an unknown quantity at this point 
Solved Threads: 2
foosion foosion is offline Offline
Light Poster

Re: Emailing unicode chars?

 
0
  #4
Aug 16th, 2009
I already tried his code. Fails in 3.1
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC