Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51541

Re: [python] email 8bit encoding

X-Received by 10.224.54.73 with SMTP id p9mr80225026qag.1.1375156593371; Mon, 29 Jul 2013 20:56:33 -0700 (PDT)
X-Received by 10.49.64.37 with SMTP id l5mr1503007qes.32.1375156593349; Mon, 29 Jul 2013 20:56:33 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!f7no104120qan.0!news-out.google.com!ce7ni20qab.0!nntp.google.com!fx3no104839qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Mon, 29 Jul 2013 20:56:33 -0700 (PDT)
In-Reply-To <mailman.5252.1375124803.3114.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=65.183.81.59; posting-account=h7ZmAgoAAAChnNHfIDF1M6YGHuonryl5
NNTP-Posting-Host 65.183.81.59
References <36aa5535-a821-4d7e-8414-1e40820705e4@googlegroups.com> <mailman.5252.1375124803.3114.python-list@python.org>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <eaea5140-8873-44d8-988f-a64413dca2eb@googlegroups.com> (permalink)
Subject Re: [python] email 8bit encoding
From rurpy@yahoo.com
Injection-Date Tue, 30 Jul 2013 03:56:33 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:51541

Show key headers only | View raw


On 07/29/2013 12:16 AM, W. Trevor King wrote:
> On Sun, Jul 28, 2013 at 04:41:27PM -0700, rurpy@yahoo.com wrote:
>> How, using Python-3.3's email module, do I "flatten" (I think
>> that's the right term) a Message object to get utf-8 encoded
>> body with the headers:
>>  Content-Type: text/plain; charset=UTF-8
>>  Content-Transfer-Encoding: 8bit
>> when the message payload was set to a python (unicode) string?
> 
> I asked about this a while back [1], but never got a response.  My
> current best-guess is here [2].  My fallback flattening works for
> everything except the 8-bit encoded messages using the UTF-16 charset,
> but it's pretty ugly.
> 
> Let me know if you figure out something cleaner :).
> 
> Cheers,
> Trevor
> 
> [1]: http://thread.gmane.org/gmane.comp.python.general/725425
> [2]: https://github.com/wking/rss2email/blob/master/rss2email/email.py#L226

Thanks, that was very helpful.

My code is just a quick utility tool for internal use so
I am able to be fairly hackish without shame. :-)

Since I am synthesizing the mails from scratch and the 
encoding requirements fairly simple, I could probably
dispense with the email/smtplib packages altogether and 
just pipe my text directly to sendmail.  But I thought
using Python's email package would be easier.  Silly me.

Thanks again.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

email 8bit encoding rurpy@yahoo.com - 2013-07-28 16:41 -0700
  Re: [python] email 8bit encoding "W. Trevor King" <wking@tremily.us> - 2013-07-28 23:16 -0700
    Re: [python] email 8bit encoding rurpy@yahoo.com - 2013-07-29 20:56 -0700
  Re: email 8bit encoding Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-07-29 22:52 +0200
    Re: email 8bit encoding rurpy@yahoo.com - 2013-08-01 08:20 -0700
      Re: email 8bit encoding Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-02 13:19 +0200
      Re: email 8bit encoding Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-02 14:12 +0200

csiph-web