Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29745

Why are the same contents decoded differently according to mail clients?

$
0
0

My code checks a mailbox, and forwards every mail to another user.
But I found out that the same contents are decoded differently according to mail clients(I mean, when sent with account@gmail.com, with account@naver.com, and etc).

For example:what I typed,
subject: subject
content: this is content

for mail client 1:
358 2020-04-22 18:12:23,249: run: DEBUG: subject has come as: =?utf-8?B?c3ViamVjdA==?=
359 2020-04-22 18:12:23,249: run: DEBUG: content has come as: dGhpcyBpcyBjb250ZW50Cg==

for mail client 2:
178 2020-04-22 18:12:09,636: run: DEBUG: subject has come as: =?utf-8?B?c3ViamVjdA==?=
179 2020-04-22 18:12:09,636: run: DEBUG: content has come as: dGhpcyBpcyBjb250ZW50Cg==

for mail client 3:
300 2020-04-22 18:12:16,494: run: DEBUG: subject has come as: subject
301 2020-04-22 18:12:16,494: run: DEBUG: content has come as: this is content

For 1 and 2, they are the same.
But for 3, it is different.

My code using imaplib sample:

typ, rfc = self.mail.fetch(num, '(RFC822)')raw_email = rfc[0][1]raw_email_to_utf8 = raw_email.decode('utf-8')msg=email.message_from_string(raw_email_to_utf8)content = msg.get_payload() #This is printed for the above debugging log.

Because of this, some mails are sent with wierd contents.(subjects are encoded well again)

Why this difference, and how can I get the contents for differently decoded ones?


Viewing all articles
Browse latest Browse all 29745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>