From eedb9c0e6743aa8739fc01a68145be5a605a7f3e Mon Sep 17 00:00:00 2001 From: Nicholas van Oudtshoorn Date: Thu, 22 Aug 2013 16:56:25 +0800 Subject: [PATCH] Bug 10777: email 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 Signed-off-by: Galen Charlton (cherry picked from commit 25076dec54f06b6a7938f4a6cda0a80a1d3d51e4) Signed-off-by: Fridolin Somers --- 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 2357ed8b35..18e175d835 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; -- 2.39.5