in reply to email pdf file - file damaged

I have my reservations about IO::All, especially once you move from a hardcoded filename to anything variable because it reopens the security hole that was fixed by introducing the three argument form of open. Additionally, my guess is that you're running all of this under Windows and that IO::All doesn't know about binmode. From delving into the code of IO::All::File and IO::All, maybe you could alleviate this by using

body => io( 'document.pdf' )->binary(1)->all,

but I would entirely stay away from IO::All for it heaps too much magic onto magic and relies on the undocumented assumptions made by Ingy.

Also see Mumble file mumble corrupt by jmcnamara

Replies are listed 'Best First'.
Re^2: email pdf file - file damaged
by madison.sacd (Novice) on May 07, 2007 at 07:29 UTC
    Thanks for the reply but after modify, I still couldn't open the attached pdf file. I am running this under fedora 6. Any other suggestion? BTW, If you entirely stay away from IO::All, what method would you call when you want to attach a file to email?

      I would maybe use File::Slurp::slurp or write my own file slurper:

      sub slurp { open my $fh, "<", $_[0] or die "Couldn't open '$_[0]' for reading: $!"; binmode $fh; local $/; my $result = <>; };

      Maybe your (Content-)Encoding of quoted-printable is inappropriate for the type of file you're sending? I would think a Content-Encoding that uses base64 would be better maybe, if Email::Simple supports such. But then, I use MIME::Lite for most of my mailing needs.

        Thanks, Corion. After I changed to use "base64". It works fine now. The reason I used "quoted-printable" is that the example code on cpan is written like this. It seems not working now. Again, thank you so much.