Just a little addition... I was having problems with the email subject appearing to be UTF8 but coming through as =?UTF-8?B?SGVsbG/wn5iD8J+YhPCfmIHwn5iG?=
Adding the policy=default to the message_from_bytes call seems to have solved this.
I changed this line: message = message_from_bytes(envelope.content) to this: message = message_from_bytes(envelope.content, policy=default)
Now UTF8 subjects come through correctly.