https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37984

            Bug ID: 37984
           Summary: Binary attachment cannot be sent via
                    C4::Letters::EnqueueLetter()
 Change sponsored?: ---
           Product: Koha
           Version: 21.11
          Hardware: Macintosh
                OS: Mac OS
            Status: NEW
          Severity: new feature
          Priority: P5 - low
         Component: Notices
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
                CC: [email protected]

I use koha testing docker in Mac OS.

This code does not send a valid e-mail binary attachment:

$pdf_binary_content = ...;
my @attachments = (
       {
           filename => 'attachment.pdf',
           type => 'application/pdf',
           content => $pdf_binary_content,
       }
   );
my $message_id = C4::Letters::EnqueueLetter({
       ...
       ...
       ...
       attachments => \@attachments,
   });

because in C4::Letters is in _add_attachments function attachment encoding:
...
Encode::encode( "UTF-8", $attachment->{content} )
...

I can't encode a binary file...



Possible solution (C4::Letters):

sub _add_attachments {
...
    foreach my $attachment ( @$attachments ) {
        $message->attach(

            #
##################################################################
            # Original code: Encode::encode( "UTF-8", $attachment->{content} ),
            # New code:
            defined $attachment->{binary} ? $attachment->{content} :
Encode::encode( "UTF-8", $attachment->{content} ),
            #
##################################################################

            content_type => $attachment->{type} || 'application/octet-stream',
            name         => $attachment->{filename},
            disposition  => 'attachment',
        );
    }
...
}

my @attachments = (
        {
            ...
            binary => 1,
        }
    );
my $message_id = C4::Letters::EnqueueLetter({
       ...
       ...
       ...
       attachments => \@attachments,
   });

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to