Hellow Perl Monks, I am kinda new perl user, so sorry for basic question. I tried some stuff learning frm the internet but it dint work out for me hence came to the place I love, perlmonks!!! Please save my day. I have a script which I wrote that reads last 24 hr information from a log file, and emails it to me in a good format. However, I would like this table to be printed in HTML table format and send it as a mail to me in HTML format. Below is the script that works for me now:
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>; @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";
The content of the email outputs as below:
Sun Jul 21 07:20:22 2013 15 Success 17 sec + 0.88 MB/sec 7.00 Mb/sec 52.00 MB/min Sun Jul 21 06:20:22 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sun Jul 21 05:20:22 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sun Jul 21 04:20:22 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sun Jul 21 03:20:22 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sun Jul 21 02:20:22 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sun Jul 21 01:20:22 2013 16 Success 19 sec + 0.84 MB/sec 6.00 Mb/sec 50.00 MB/min Sun Jul 21 00:20:22 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sat Jul 20 23:20:23 2013 16 Success 16 sec + 1.00 MB/sec 8.00 Mb/sec 60.00 MB/min Sat Jul 20 22:20:23 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sat Jul 20 21:20:23 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sat Jul 20 20:20:22 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sat Jul 20 19:20:23 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sat Jul 20 18:20:23 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sat Jul 20 17:20:22 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sat Jul 20 16:20:22 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sat Jul 20 15:20:23 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sat Jul 20 14:20:23 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sat Jul 20 13:20:23 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sat Jul 20 12:20:22 2013 136 Success 2 min 39 s +ec 0.86 MB/sec 6.00 Mb/sec 51.00 MB/min Sat Jul 20 11:20:22 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sat Jul 20 10:20:23 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min Sat Jul 20 09:20:25 2013 16 Success 18 sec + 0.89 MB/sec 7.00 Mb/sec 53.00 MB/min Sat Jul 20 08:20:23 2013 16 Success 17 sec + 0.94 MB/sec 7.00 Mb/sec 56.00 MB/min

but you know its just plaintext. I tried using the module HTML::Table, but pls help me illustrating it and using it to send colorful table in email. Thanks!!! Sid

In reply to Logfile to HTML and MIME EMail table by sidsinha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.