Answer the question
In order to leave comments, you need to log in
What is the encoding in imap?
I'm trying to decode mail received via imap using perl (I use Net::IMAP::Simple)
I get the following lines: Lebedev's
=?UTF-8?B?RGF2aWQgS3VyZXh5YW4g0L/RgNC40LPQu9Cw0YjQsNC10YIg0JLQsNGBINGB?=
decoder coped with the decoding and wrote that it is base64
But if you try
use MIME::Base64;
print decode_base64('=?UTF-8?B?RGF2aWQgS3VyZXh5YW4g0L/RgNC40LPQu9Cw0YjQsNC10YIg0JLQsNGBINGB?=');
Answer the question
In order to leave comments, you need to log in
This is base64. It is necessary to decode what is after after "=?UTF-8?B?"
Answer: "David Kurexyan invites you with"
This is decoded with Encode::MIME::Header.
In addition to B (base64), there may also be Q (quoted-printable).
First, not in IMAP, but in the mail header. This is how all non-ASCII mail headers are arranged - only characters with the most significant bit 0 are allowed inside, i.e. UTF-8 is not directly valid; it is encoded in BASE64 and thus placed in the headers.
Secondly, even without knowing the answer, it would be logical to assume that =?UTF-8?B? is a "preamble" describing the format of the subsequent data, from? before? (which is not a base64 encoded character).
Thirdly, if your header looks like
Subject: =?UTF-8?B?bla-bla-bla?=
(spaces) =?UTF-8?B?bla-bla-bla?=
then all these lines need to be unpacked independently and then do the concatenation.
In general, read RFC5321 and 5322. The specific pearl module was suggested above.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question