vitoco has asked for the wisdom of the Perl Monks concerning the following question:
Hi! This seems to be quite repetitive but I still cannot figure out how to solve this...
I'm using Email::MIME::CreateHTML to build an email that contents an HTML message with a PNG image that I want to include in the email encoded as BASE64. Everything seems to work OK except for the fact that in the email, when displayed by the recipient's email client, the image is broken. I've decoded the BASE64 part of the multipart body and found that the encoded file had 1 byte less that the original image file. So I binary compared the original and decoded files and found that the missing byte was because read_file in File::Slurp always does a CR/LF into NL substitution with the asumption that it is a text file just because I'm running in a Windows machine ($buf =~ s/\015\012/\n/g if $is_win32 ;), and this binary image just happens to have that sequence of bytes in it's header.
Is there a way to replace the read_file method, without editing the modules or rewriting a whole resolver, or to force it to use binmode? Well, Slurp accepts some options like binmode, but this obvously needs CreateHTML to send that option to it, and I'm not sure if that works with small binary files.
Thanks!
|
|---|