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>
(cherry picked from commit 25076dec54)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
e83b77985e
commit
eedb9c0e67
|
|
@ -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 = "<html><head><style>tr:nth-child(n+1) { background-color: #ccc;}</style></head><body>$message</body></html>";
|
||||
%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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue