in reply to Re^3: Using Net::SMTP to send pdf attachment
in thread Using Net::SMTP to send pdf attachment
Thanks for confirming that the pdf is a binary file.
I tried with the code below (by astrobal from http://www.perlmonks.org/?node_id=1189197) but the pdf file opens with nothing:
$smtp->datasend("Content-Type: application/pdf; name=\"$attachBinaryFi +le\"\n"); $smtp->datasend("Content-Transfer-Encoding: base64\n"); $smtp->datasend("Content-Disposition: attachment; filename=\"$attachBi +naryFile\"\n"); $smtp->datasend("\n"); open(DAT, "$path/$attachBinaryFile") || die("Could not open binary fil +e!"); binmode(DAT); local $/=undef; while (read(DAT, $picture, 4096)) { $buf = &encode_base64( $picture ); $smtp->datasend($buf); } close(DAT); $smtp->datasend("\n"); $smtp->datasend("--$boundary\n");
I changed "Content-Type: image/jpeg;" in his code to "Content-Type: application/pdf;".
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Using Net::SMTP to send pdf attachment
by poj (Abbot) on Mar 16, 2018 at 15:40 UTC | |
by Anonymous Monk on Mar 16, 2018 at 15:57 UTC | |
by poj (Abbot) on Mar 16, 2018 at 17:43 UTC | |
by Anonymous Monk on Mar 17, 2018 at 00:23 UTC | |
by poj (Abbot) on Mar 17, 2018 at 15:55 UTC | |
|
In Section
Seekers of Perl Wisdom