in reply to Sending email attachments

Hi
Try this:
use MIME::QuotedPrint; use MIME::Base64; use Mail::Sendmail 0.75; # doesn't work with v. 0.74! %mail = ( from => 'you@domain.tld', to => 'whoever@someplace.tld', subject => 'Test attachment', ); $boundary = "====" . time() . "===="; $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; $message = encode_qp( "Some message" ); $file = $^X; # This is the perl executable open (F, $file) or die "Cannot read $file: $!"; binmode F; undef $/; $mail{body} = encode_base64(<F>); close F; $boundary = '--'.$boundary; $mail{body} = <<END_OF_BODY; $boundary Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable $message $boundary Content-Type: application/octet-stream; name="$^X" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="$^X" $mail{body} $boundary-- END_OF_BODY sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";
Enjoy!


we're born with our eyes closed and our mouths wide open, and we spend our entire life trying to rectify that mistake of nature. - anonymous.

Replies are listed 'Best First'.
Re^2: Sending email attachments
by Anonymous Monk on Jan 10, 2019 at 06:45 UTC
    Hi, this doesn't seem to work for outlook !. No file gets attached. The body contains the content itself