use Modern::Perl;
use CGI qw ( -utf8 );
-use Encode qw(encode);
-use Carp;
-use Try::Tiny;
-
-use C4::Biblio;
-use C4::Items;
-use C4::Auth;
-use C4::Output;
-use C4::Templates ();
+use Encode;
+use Carp qw( carp );
+use Try::Tiny qw( catch try );
+
+use C4::Biblio qw(
+ GetBiblioData
+ GetMarcAuthors
+ GetMarcBiblio
+ GetMarcSubjects
+);
+use C4::Items qw( GetItemsInfo );
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_and_exit output_html_with_http_headers );
+use C4::Templates;
use Koha::Email;
use Koha::Token;
-my $query = new CGI;
+my $query = CGI->new;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
{
$subject = "no subject";
}
- my $email = Koha::Email->create(
- {
- to => $email_add,
- subject => $subject,
- }
- );
-
my $email_header = "";
if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
$email_header = $1;
$email_header =~ s|\n?(.*)\n?|$1|;
- $email_header = Encode::encode("UTF-8", $email_header);
}
if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
$body = $1;
$body =~ s|\n?(.*)\n?|$1|;
- $body = Encode::encode("UTF-8", $body);
}
my $THE_body = <<END_OF_BODY;
$body
END_OF_BODY
- $email->text_body( $THE_body );
- $email->attach(
- $iso2709,
- content_type => 'application/octet-stream',
- name => 'basket.iso2709',
- disposition => 'attachment',
- );
-
try {
+
+ my $email = Koha::Email->create(
+ {
+ to => $email_add,
+ subject => $subject,
+ }
+ );
+
+ $email->text_body( $THE_body );
+ $email->attach(
+ Encode::encode( "UTF-8", $iso2709 ),
+ content_type => 'application/octet-stream',
+ name => 'basket.iso2709',
+ disposition => 'attachment',
+ );
+
my $library = Koha::Patrons->find( $borrowernumber )->library;
$email->send_or_die({ transport => $library->smtp_server->transport });
$template->param( SENT => "1" );