package MAILER; BEGIN { } use MIME::Lite; use Net::SMTP; sub send_mail { ### Adjust sender, recipient and your SMTP mailhost # my ($subject, $mail_host, $messageBody, $to_address, $date, $cc_address, $my_file_zip) = @_; ### Send the Message MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send; my $from_address = ''; ### Adjust subject and body message ### Adjust the filenames my $your_file_zip = "Report_$date.html"; ### Create the multipart container $msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; ### Add the text message part $msg->attach ( Type => 'TEXT', Data => $messageBody ) or die "Error adding the text message part: $!\n"; ### Add the GIF file ### Add the ZIP file $msg->attach ( Type => 'application/zip', Path => $my_file_zip, Filename => $your_file_zip, Disposition => 'attachment' ) or die "Error adding $file_zip: $!\n"; ### Send the Message MIME::Lite->send('smtp', $mail_host,Timeout=>60); $msg->send; return 0; } return 1; END { }