- # Sending mail
- if ( sendmail %mail ) {
- # do something if it works....
- $template->param( SENT => "1" );
+ try {
+ my $email = Koha::Email->create(
+ {
+ to => $email,
+ subject => $subject,
+ }
+ );
+ $email->text_body( $THE_body );
+ $email->attach(
+ Encode::encode( "UTF-8", $iso2709 ),
+ content_type => 'application/octet-stream',
+ name => 'list.iso2709',
+ disposition => 'attachment',
+ );
+ my $library = Koha::Patrons->find( $borrowernumber )->library;
+ $email->transport( $library->smtp_server->transport );
+ $email->send_or_die;
+ $template->param( SENT => "1" );