use HTML::Table; use Mail::Sendmail; my $outfile = 'log.txt'; #Read the last 24 lines from the file which is the latest 24 transfers and generate a email. unshift @{$Mail::Sendmail::mailcfg{'smtp'}} , 'mail.dadada.com'; $Mail::Sendmail::mailcfg{'from'} = "dadada\@dadada.com"; open(FILE, $outfile) or die "Can't open File: File does not exist $!"; @file = ; @file = reverse(@file); close FILE; for (0..23) { $dayData .= "$file[$_]"; } my %mail = ( To => 'dadada@dadada.com', Subject => "Report - Transfer Summary - $date", Message => "Mail auto generated on $date\n\n\n $dayData", ); sendmail( %mail ) or die "Error: $Mail::Sendmail::error\n"; printf "\nMail Sent /@ $date\n";