Is there any way to make sense of these E-Mail subjects?

Python python at example.invalid
Fri Dec 24 11:41:00 EST 2021


Chris Green wrote:
>        Subject: [SPAM] =?UTF-8?B?8J+TtyBKb2huIEJheHRlci1C?=
>       =?UTF-8?B?cm93biByZWNlbnRseSBw?=
>       =?UTF-8?B?b3N0ZWQgYSBuZXcgcGhv?=
>       =?UTF-8?B?dG8=?=
> 
> It looks like some sort of mis-encoding of UTF-8 strings, can anyone
> suggest what might be going on and/or a way to get some sense out of
> this?

It's not mis-encoding, it the standard way to embed non-ascii
characters in the header. ?UTF-8?B? means base64 encoded utf-8,
then the content is on multiple lines:

$ base64 -d < t
📷 John Baxter-Brown recently posted a new photo

email.header.decode_header should be able to handle it.



More information about the Python-list mailing list