Another 2 to 3 mail encoding problem

Cameron Simpson cs at cskk.id.au
Thu Aug 27 05:16:47 EDT 2020


On 27Aug2020 09:31, Chris Green <cl at isbd.net> wrote:
>I can provoke the error simply by sending myself an E-Mail with
>accented characters in it.  I'm pretty sure my Linux system is set up
>correctly for UTF8 characters, I certainly seem to be able to send and
>receive these to others and I even get to see messages in other
>scripts such as arabic, chinese, etc.

See:

    https://docs.python.org/3/library/email.generator.html#module-email.generator

While is conservatively writes ASCII (and email has extensive support 
for encoding other character sets into ASCII), you might profit by 
looking at the BytesGenerator in that module using the policy parameter, 
which looks like it tunes the behaviour of the flatten method.

I have a mailfiler of my own, which copes just fine.

It loads messages with email.parser.Parser, whose .parse() method 
returns a Message, and Message.as_string() seems to write happily into a 
text file for me. I run _all_ my messages through this stuff.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list