Hi all I have nicked this script from
http://alma.ch/perl/Mail-Sendmail-FAQ.htm#attachments
The thing is all works well except for the fact the attachment arrives named as
perl(somenumber.kb)
Does any one no how I can name the attachment the same as the value passed to file
handle F by $file.
#! /usr/bin/perl -w
use MIME::QuotedPrint;
use MIME::Base64;
use Mail::Sendmail 0.75; # doesn't work with v. 0.74!
%mail = (
SMTP => 'mail.aslib.com',
from => '[EMAIL PROTECTED]',
to => '[EMAIL PROTECTED]',
subject => 'Test attachment',
);
$boundary = "====" . time() . "====";
$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
$file = "test.doc";
$message = encode_qp( "$file" );
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";