I had a project where I needed to retrieve messages from my IMAP mailbox of my Bulgarian gmail. The problem is that I didn’t know what to call it or how to figure out what to call it. I tried the equivilent in English “All Mail”, folder not found. I tried the name of the mailbox in Bulgarian in UTF-8 “Цялата поща”, that just gave an error. I found out that there is some sort of encoding for IMAP for international boxes from a bug report{.broken_link} for Thunderbird, a great open-source email client. It said that I needed to look at RFC3501 to see the standard for how the mailbox should be encoded. It turns out that it’s a variant of UTF-7, the 7-bit universal format. It took a while to get a converter going, but it looks a little like this:
[shell]
echo
[/shell]
so, for my “All Mail” box, which is Цялата поща in Bulgarian, I would do:
[shell]
echo Цялата поща | iconv -f utf-8 -t utf-7 | sed -e ‘s/+/\&/g’ -e ‘s/>/-/g’ -e ‘s#/#,#g’ |
[/shell]
So, I needed to update my getmail configuration, replacing “All Mail” with the string that resulted: “&BCYETwQ7BDAEQgQw- &BD8EPgRJBDA-“. This turned out to have some weird issues since the characters that the modified UTF-7 was using were control characters in sed, so my sed command became a little more complicated:
[shell]
sed -i -e “s/All Mail/$(echo -n Цялата поща | iconv -f utf-8 -t utf-7 | sed -e ‘s/+/\\&/g’ -e ‘s/>([^-])/\-\1/g’ -e ‘s#/#,#g’)/g” getmail_clashthebunny |
[/shell]