use strict; use warnings; use MIME::QuotedPrint; use HTML::Table; use Mail::Sendmail; # Read lines open(FILE, 'log.txt') or die "Can't open File: File does not exist $!"; my @file = ; chomp @file; @file = reverse(@file); close FILE; # Create Table my $table = new HTML::Table; $table->addRow(split /\s\s+/) for (@file[0..23]); $table->setColBGColor(3, 'Green'); $table->setColFormat(1, '', ''); $table->setColFormat(5, '', ''); # Create HTML email with table content unshift @{$Mail::Sendmail::mailcfg{'smtp'}}, 'localhost'; my $plain = encode_qp "html log included"; my $html = encode_qp $table; my $boundary = "====" . time() . "===="; my $date = Mail::Sendmail::time_to_date(); my %mail = ( From => 'me@localhost', To => 'user@host.com', Subject => "Report - Transfer Summary - $date", 'content-type' => "multipart/alternative; boundary=\"$boundary\"", ); $mail{body} = <$html --$boundary-- END_OF_BODY # Send email and finish sendmail( %mail ) or die "Error: $Mail::Sendmail::error\n"; printf "\nMail Sent @ $date\n";