I was writing something that pulls off file attachmets from an e-mail through IMAP.
I used Mail::IMAPClient to access the email.
The attachments are encoded base64 so I did $imap->bodypart_string($uid,2) to get the base64 encoded file , just because I knew precisely that the second MIME part was supposed to be my file.
Now I had to decode it so I thought I know , "I'll use MIME::Base64::decode_base64 on what I got above and store that in a file" , and that's exactly what I did only to find out later that the file that was supposed to be decoded wound up corrupt , it was a 7z file and couldn't be opened any more.
So I thought , what could have changed ? And I went and ran kdiff3 modif.7z orig.7z and it told me:
"File A and B have equal text, but are not binary equal" then I got really mad and I diffed them to see what's going on , I couldn't make much out of the diff of two binaries
Again I thought what could've been the trouble so I thought I should shave the \r\n off the end of the lines before I decode_base64 , that didn't work either.
Then I just dropped the whole thing , outputted the base64 to a file and tried to decode it with base64 -d modif.base64 and I got <some bytes..> invalid input . After that, by reading the manpage of base64 I got to know that
-i, --ignore-garbage
When decoding, ignore non-alphabet characters.
So I decided to use that , and then base64 -i -d modif.base64 > file.7z.
Apparently that worked and I got my file back and also found a port of base64 on Windows.
But I don't like this , I've added some binaries as dependencies.. I'd like to find alternative encodings to base64 when sending some e-mail, what modules and alternatives are there on CPAN ? I'm interested in portable modules, and how I can use them in combination with Email::Stuff
Best regards,
Stefan
P.S. It turned out to only be a problem for Windows , that MIME::Base64 has , it's most likely a bug that I will report , I have a testcase ready with a base64 file that proves it.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |