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 <mtompset@hotmail.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
2f0aac8970
commit
25076dec54
1 changed files with 18 additions and 7 deletions
|
@ -241,14 +241,25 @@ foreach my $report_id (@ARGV) {
|
||||||
$message .= $csv->string() . "\n";
|
$message .= $csv->string() . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($email){
|
if ($email){
|
||||||
my %mail = (
|
my %mail;
|
||||||
To => $to,
|
if ($format eq 'html') {
|
||||||
From => $from,
|
$message = "<html><head><style>tr:nth-child(n+1) { background-color: #ccc;}</style></head><body>$message</body></html>";
|
||||||
Subject => encode('utf8', $subject ),
|
%mail = (
|
||||||
Message => encode('utf8', $message )
|
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;
|
sendmail(%mail) or carp 'mail not sent:' . $Mail::Sendmail::error;
|
||||||
} else {
|
} else {
|
||||||
print $message;
|
print $message;
|
||||||
|
|
Loading…
Reference in a new issue