use MIME::Lite;
#.....
sub Mail_File {
my $fileName = $_[0]; # To attach
my $myMailAddress = $_[1]; # Your email address / address e-mail should appear from
my $email_address = $_[2]; # Recipients mail address
my $title = $_[3]; # Email title
my $body_message = $_[4]; # Text in main part of e-mail
my $fileType = $_[5]; # Know whether attachment is 'BINARY' or 'TEXT'
my $fileName = $_[6]; # Name of file to attach (including path)
my $outFileName = $_[7]; # Name to give e-mail attachment
# Create MIME::Lite mail object
my $msg = MIME::Lite->new(
From => $myMailAddress,
To => $email_address,
Subject => $title,
Type => 'multipart/mixed',
);
# Main Body of message
$msg->attach(
Type => 'TEXT',
Data => $body_message
);
# Attach file here
$msg->attach(Type => $fileType,
Path => $fileName,
Filename => $outFileName,
Disposition => 'attachment'
);
# Send e-mail
$msg->send();
} # end sub Mail_File