Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: email pdf file - file damaged

by madison.sacd (Novice)
on May 07, 2007 at 07:29 UTC ( [id://613898]=note: print w/replies, xml ) Need Help??


in reply to Re: email pdf file - file damaged
in thread email pdf file - file damaged

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?

Replies are listed 'Best First'.
Re^3: email pdf file - file damaged
by Corion (Patriarch) on May 07, 2007 at 07:34 UTC

    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.
        I know this is a SUPER old thread - but THANK YOU! I was wondering why my attached PDF was coming up with an error about the font not being accessible. I was doing:
        push @parts, Email::MIME->create( attributes => { filename => $filename, content_type => "application/pdf", encoding => "quoted-printable", name => $filename, }, body => io( $opts->{attach_file} )->binary->all, )
        But tweaked it to use base64 and it works fine now:
        push @parts, Email::MIME->create( attributes => { filename => $filename, content_type => "application/pdf", encoding => "base64", name => $filename, }, body => io( $opts->{attach_file} )->binary->all, )


        Would never have thought of that!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://613898]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-10-12 15:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.