From 4a709648b360b9e45cccb9a66e323808d27d0443 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Tue, 17 Dec 2019 14:49:51 +0000 Subject: [PATCH] Bug 22838: Remove MIME header warnings from runreports.pl Test plan: - create a savedsql report - run misc/cronjob/runreport.pl with options --format set to html and --to any email - check plack errors log, you should get a warning - apply patch - repeat runreport.pl step - check plack errors log, no additional warning there should be --- misc/cronjobs/runreport.pl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index 6732afae9c..fbea88944a 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -314,10 +314,7 @@ foreach my $report_id (@ARGV) { } if ($email) { my $args = { to => $to, from => $from, subject => $subject }; - if ( $format eq 'html' ) { - $message = "$message"; - $args->{contenttype} = 'text/html'; - } + my $email = Koha::Email->new(); my %mail = $email->create_message_headers($args); $mail{Data} = $message; @@ -325,6 +322,12 @@ foreach my $report_id (@ARGV) { my $msg = MIME::Lite->new(%mail); + if ( $format eq 'html' ) { + $message = "$message"; + $args->{contenttype} = 'text/html'; + } + $msg-> attr("content-type" => $args->{contenttype}); + $msg->attach( Type => "text/$format", Data => encode( 'utf8', $message ), -- 2.20.1