Problem with pyramid_mailer topic header

When I send an email using pyramid_mailer in the gmail web client, everything looks fine, but any subject desktop clients contain question marks, for example: enter image description here

If the subject code's open source email is as follows:

 Subject: =?utf-8?b?W9CS0LXQsS3Qk9CY0KEt0LrQvtC70YzRhtC10LLQsNC90LjQtV0g0JDQvdC+0L3Q?= =?utf-8?b?uNC8IDIwMTItMTAtMTggMTc6NTg6MzIg0YHQvtC30LTQsNC7INC30LDQv9C40YHR?= =?utf-8?b?jCAjMTM1OSAo0LrQvtC70YzRhtC10LLQsNC90LjQtSk=?= 

As you can see, it is divided into three parts. Try executing python code:

 import email.header print email.header.decode_header('=?utf-8?b?W9CS0LXQsS3Qk9CY0KEt0LrQvtC70YzRhtC10LLQsNC90LjQtV0g0JDQvdC+0L3Q?=')[0][0] print email.header.decode_header('=?utf-8?b?uNC8IDIwMTItMTAtMTggMTc6NTg6MzIg0YHQvtC30LTQsNC7INC30LDQv9C40YHR?=')[0][0] print email.header.decode_header('=?utf-8?b?jCAjMTM1OSAo0LrQvtC70YzRhtC10LLQsNC90LjQtSk=?=')[0][0] 

We get the following result:

 [--]    2012-10-18 17:58:32     #1359 () 

How can I get rid of this problem?

+4
source share
2 answers

I just fixed the fix for this so that you can get it in repoze.sendmail 4.0 or 4.0b2, depending on what the next release is.

+1
source

yep .. sounds like an error to me too ... python base64.encodestring () splits the default long lines into multiple lines, which in my opinion is causing the problem.

the solution would be to replace newlines in the objects used or use binascii.b2a_base64 for encoding.

0
source

Source: https://habr.com/ru/post/1440603/


All Articles