[Email-SIG] Converting to quoted printable encoding

Nicholas Cole nicholas.cole at gmail.com
Wed Sep 24 22:10:32 CEST 2008


On Wed, Sep 24, 2008 at 8:25 PM, Nicholas Cole <nicholas.cole at gmail.com> wrote:
> My naive attempt to convert a MIMEText message part to quoted
> printable (having read the documentation) looked something like this:
>
> E = email.mime.text.MIMEText("This is some text")
> email.encoders.encode_quopri(E)
> print E.as_string()
>
> But it yields a message with two Content-Transfer-Encoding headers.
>
> I'm assuming that this is not a bug - but what is "The Right Way"(TM)
> to change the encoding of text?

I can't see that this isn't a bug - in that encode_quopri is (as the
documentation says) adding a header, but not replacing the one that
was there already.

But I am confused.  Doing this results in a truly mangled message,
suggesting that encode_quopri is not as aware of existing encoding as
I thought:

E = email.mime.text.MIMEText("This is some text")
email.encoders.encode_quopri(E)
email.encoders.encode_quopri(E)

So, it looks like I'm going to be better off using the quopri module directly...

Best,

N


More information about the Email-SIG mailing list