From e68c8d6e4de649efdd0966478958bdda3292836c Mon Sep 17 00:00:00 2001 From: Nicholas van Oudtshoorn Date: Thu, 22 Aug 2013 16:56:25 +0800 Subject: [PATCH] [PASSED QA] Bug 10777 - Send html reports with the proper Content-Type The misc/cronjobs/runreport.pl allows for sending html reports via email. The problem is that the Content-Type isn't set to text/html, which means that the generated html email isn't displayed properly. This patch set the Content-Type, and also adds a tiny bit of CSS to potentially alternate row colours (just to make long reports a bit easier on the eye!) TEST PLAN ---------- 1. Run the script similar to this: ./misc/cronjobs/runreport.pl --format=html --to=YOUREMAIL --subject="Bad Formatting!" REPORTNUMBER 2. Look at the email - the html code should by visible and ugly. 3. apply the patch 4. Run the script again. 5. Look at the email - the data should look nicer now. Signed-off-by: Mark Tompsett Signed-off-by: Martin Renvoize --- misc/cronjobs/runreport.pl | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index 2357ed8..18e175d 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -241,14 +241,25 @@ foreach my $report_id (@ARGV) { $message .= $csv->string() . "\n"; } } - if ($email){ - my %mail = ( - To => $to, - From => $from, - Subject => encode('utf8', $subject ), - Message => encode('utf8', $message ) - ); + my %mail; + if ($format eq 'html') { + $message = "$message"; + %mail = ( + To => $to, + From => $from, + 'Content-Type' => 'text/html', + Subject => encode('utf8', $subject ), + Message => encode('utf8', $message ) + ); + } else { + %mail = ( + To => $to, + From => $from, + Subject => encode('utf8', $subject ), + Message => encode('utf8', $message ) + ); + } sendmail(%mail) or carp 'mail not sent:' . $Mail::Sendmail::error; } else { print $message; -- 1.7.10.4