Printing UTF-8 mail to terminal

Cameron Simpson cs at cskk.id.au
Fri Nov 1 17:47:39 EDT 2024


On 01Nov2024 10:10, Loris Bennett <loris.bennett at fu-berlin.de> wrote:
>as expected.  The non-UTF-8 text occurs when I do
>
>  mail = EmailMessage()
>  mail.set_content(body, cte="quoted-printable")
>  ...
>
>  if args.verbose:
>      print(mail)
>
>which is presumably also correct.
>
>The question is: What conversion is necessary in order to print the
>EmailMessage object to the terminal, such that the quoted-printable
>parts are turned (back) into UTF-8?

Do you still have access to `body` ? That would be the original message 
text? Otherwise maybe:

     print(mail.get_content())

The objective is to obtain the message body Unicode text (i.e. a regular 
Python string with the original text, unencoded). And to print that.


More information about the Python-list mailing list