|
Lines 34-40
use Koha::Email;
Link Here
|
| 34 |
use Koha::Patrons; |
34 |
use Koha::Patrons; |
| 35 |
use Koha::Token; |
35 |
use Koha::Token; |
| 36 |
|
36 |
|
| 37 |
my $query = new CGI; |
37 |
my $query = CGI->new; |
| 38 |
|
38 |
|
| 39 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( |
39 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( |
| 40 |
{ |
40 |
{ |
|
Lines 127-152
if ( $email_add ) {
Link Here
|
| 127 |
$subject = "no subject"; |
127 |
$subject = "no subject"; |
| 128 |
} |
128 |
} |
| 129 |
|
129 |
|
| 130 |
# if you want to use the KohaAdmin address as from, that is the default no need to set it |
|
|
| 131 |
my $email = Koha::Email->create({ |
| 132 |
to => $email_add, |
| 133 |
reply_to => $email_replyto, |
| 134 |
subject => $subject, |
| 135 |
}); |
| 136 |
|
| 137 |
$email->header( 'X-Abuse-Report' => C4::Context->preference('KohaAdminEmailAddress') ); |
| 138 |
|
| 139 |
my $email_header = ""; |
130 |
my $email_header = ""; |
| 140 |
if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) { |
131 |
if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) { |
| 141 |
$email_header = $1; |
132 |
$email_header = $1; |
| 142 |
$email_header =~ s|\n?(.*)\n?|$1|; |
133 |
$email_header =~ s|\n?(.*)\n?|$1|; |
| 143 |
$email_header = Encode::encode("UTF-8", $email_header); |
|
|
| 144 |
} |
134 |
} |
| 145 |
|
135 |
|
| 146 |
if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) { |
136 |
if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) { |
| 147 |
$body = $1; |
137 |
$body = $1; |
| 148 |
$body =~ s|\n?(.*)\n?|$1|; |
138 |
$body =~ s|\n?(.*)\n?|$1|; |
| 149 |
$body = Encode::encode("UTF-8", $body); |
|
|
| 150 |
} |
139 |
} |
| 151 |
|
140 |
|
| 152 |
my $THE_body = <<END_OF_BODY; |
141 |
my $THE_body = <<END_OF_BODY; |
|
Lines 154-173
$email_header
Link Here
|
| 154 |
$body |
143 |
$body |
| 155 |
END_OF_BODY |
144 |
END_OF_BODY |
| 156 |
|
145 |
|
| 157 |
$email->text_body( $THE_body ); |
|
|
| 158 |
$email->attach( |
| 159 |
$iso2709, |
| 160 |
content_type => 'application/octet-stream', |
| 161 |
name => 'basket.iso2709', |
| 162 |
disposition => 'attachment', |
| 163 |
); |
| 164 |
|
| 165 |
if ( !defined $iso2709 ) { |
146 |
if ( !defined $iso2709 ) { |
| 166 |
carp "Error sending mail: empty basket"; |
147 |
carp "Error sending mail: empty basket"; |
| 167 |
$template->param( error => 1 ); |
148 |
$template->param( error => 1 ); |
| 168 |
} |
149 |
} |
| 169 |
else { |
150 |
else { |
| 170 |
try { |
151 |
try { |
|
|
152 |
# if you want to use the KohaAdmin address as from, that is the default no need to set it |
| 153 |
my $email = Koha::Email->create({ |
| 154 |
to => $email_add, |
| 155 |
reply_to => $email_replyto, |
| 156 |
subject => $subject, |
| 157 |
}); |
| 158 |
$email->header( 'X-Abuse-Report' => C4::Context->preference('KohaAdminEmailAddress') ); |
| 159 |
$email->text_body( $THE_body ); |
| 160 |
$email->attach( |
| 161 |
Encode::encode( "UTF-8", $iso2709 ), |
| 162 |
content_type => 'application/octet-stream', |
| 163 |
name => 'basket.iso2709', |
| 164 |
disposition => 'attachment', |
| 165 |
); |
| 171 |
my $library = $patron->library; |
166 |
my $library = $patron->library; |
| 172 |
$email->transport( $library->smtp_server->transport ); |
167 |
$email->transport( $library->smtp_server->transport ); |
| 173 |
$email->send_or_die; |
168 |
$email->send_or_die; |