- my $email = Koha::Email->new();
- my %mail = $email->create_message_headers($args);
- $mail{Data} = $message;
- $mail{Auth} = { user => $username, pass => $password, method => $method } if $username;
-
- my $msg = MIME::Lite->new(%mail);
-
- $msg->attach(
- Type => "text/$format",
- Data => encode( 'utf8', $message ),
- Filename => "report$report_id-$date.$format",
- Disposition => 'attachment',
+ else {
+ $email->text_body($message);
+ }
+
+ $email->attach(
+ Encode::encode_utf8($message),
+ content_type => "text/$format",
+ name => "report$report_id-$date.$format",
+ disposition => 'attachment',