Lines 21-28
use Modern::Perl;
Link Here
|
21 |
|
21 |
|
22 |
use Clone 'clone'; |
22 |
use Clone 'clone'; |
23 |
use File::Basename qw( basename ); |
23 |
use File::Basename qw( basename ); |
|
|
24 |
use Email::Sender::Simple qw(sendmail); |
24 |
use Encode qw( encode ); |
25 |
use Encode qw( encode ); |
25 |
use Mail::Sendmail; |
|
|
26 |
use Try::Tiny; |
26 |
use Try::Tiny; |
27 |
use DateTime; |
27 |
use DateTime; |
28 |
|
28 |
|
Lines 40-45
use Koha::Biblios;
Link Here
|
40 |
use Koha::Items; |
40 |
use Koha::Items; |
41 |
use Koha::ItemTypes; |
41 |
use Koha::ItemTypes; |
42 |
use Koha::Libraries; |
42 |
use Koha::Libraries; |
|
|
43 |
use Koha::SMTP::Server; |
44 |
|
43 |
use C4::Circulation qw( CanBookBeIssued AddIssue ); |
45 |
use C4::Circulation qw( CanBookBeIssued AddIssue ); |
44 |
|
46 |
|
45 |
use base qw(Koha::Object); |
47 |
use base qw(Koha::Object); |
Lines 1284-1290
attempts to submit the email.
Link Here
|
1284 |
|
1286 |
|
1285 |
sub generic_confirm { |
1287 |
sub generic_confirm { |
1286 |
my ( $self, $params ) = @_; |
1288 |
my ( $self, $params ) = @_; |
1287 |
my $branch = Koha::Libraries->find($params->{current_branchcode}) |
1289 |
my $library = Koha::Libraries->find($params->{current_branchcode}) |
1288 |
|| die "Invalid current branchcode. Are you logged in as the database user?"; |
1290 |
|| die "Invalid current branchcode. Are you logged in as the database user?"; |
1289 |
if ( !$params->{stage}|| $params->{stage} eq 'init' ) { |
1291 |
if ( !$params->{stage}|| $params->{stage} eq 'init' ) { |
1290 |
my $draft->{subject} = "ILL Request"; |
1292 |
my $draft->{subject} = "ILL Request"; |
Lines 1309-1315
Kind Regards
Link Here
|
1309 |
|
1311 |
|
1310 |
EOF |
1312 |
EOF |
1311 |
|
1313 |
|
1312 |
my @address = map { $branch->$_ } |
1314 |
my @address = map { $library->$_ } |
1313 |
qw/ branchname branchaddress1 branchaddress2 branchaddress3 |
1315 |
qw/ branchname branchaddress1 branchaddress2 branchaddress3 |
1314 |
branchzip branchcity branchstate branchcountry branchphone |
1316 |
branchzip branchcity branchstate branchcountry branchphone |
1315 |
branchemail /; |
1317 |
branchemail /; |
Lines 1346-1360
EOF
Link Here
|
1346 |
"No target email addresses found. Either select at least one partner or check your ILL partner library records.") |
1348 |
"No target email addresses found. Either select at least one partner or check your ILL partner library records.") |
1347 |
if ( !$to ); |
1349 |
if ( !$to ); |
1348 |
# Create the from, replyto and sender headers |
1350 |
# Create the from, replyto and sender headers |
1349 |
my $from = $branch->branchemail; |
1351 |
my $from = $library->branchemail; |
1350 |
my $replyto = $branch->branchreplyto || $from; |
1352 |
my $replyto = $library->branchreplyto || $from; |
1351 |
Koha::Exceptions::Ill::NoLibraryEmail->throw( |
1353 |
Koha::Exceptions::Ill::NoLibraryEmail->throw( |
1352 |
"Your library has no usable email address. Please set it.") |
1354 |
"Your library has no usable email address. Please set it.") |
1353 |
if ( !$from ); |
1355 |
if ( !$from ); |
1354 |
|
1356 |
|
1355 |
# Create the email |
1357 |
# Create the email |
1356 |
my $message = Koha::Email->new; |
1358 |
my $email = Koha::Email->create( |
1357 |
my %mail = $message->create_message_headers( |
|
|
1358 |
{ |
1359 |
{ |
1359 |
to => $to, |
1360 |
to => $to, |
1360 |
from => $from, |
1361 |
from => $from, |
Lines 1364-1372
EOF
Link Here
|
1364 |
contenttype => 'text/plain', |
1365 |
contenttype => 'text/plain', |
1365 |
} |
1366 |
} |
1366 |
); |
1367 |
); |
|
|
1368 |
|
1367 |
# Send it |
1369 |
# Send it |
1368 |
my $result = sendmail(%mail); |
1370 |
try { |
1369 |
if ( $result ) { |
1371 |
|
|
|
1372 |
my $smtp_server = Koha::SMTP::Servers->get_effective_server({ library => $library }); |
1373 |
Email::Sender::Simple::sendmail( $email, { transport => $smtp_server->transport } ); |
1374 |
|
1370 |
$self->status("GENREQ")->store; |
1375 |
$self->status("GENREQ")->store; |
1371 |
$self->_backend_capability( |
1376 |
$self->_backend_capability( |
1372 |
'set_requested_partners', |
1377 |
'set_requested_partners', |
Lines 1383-1397
EOF
Link Here
|
1383 |
stage => 'commit', |
1388 |
stage => 'commit', |
1384 |
next => 'illview', |
1389 |
next => 'illview', |
1385 |
}; |
1390 |
}; |
1386 |
} else { |
1391 |
} |
|
|
1392 |
catch { |
1387 |
return { |
1393 |
return { |
1388 |
error => 1, |
1394 |
error => 1, |
1389 |
status => 'email_failed', |
1395 |
status => 'email_failed', |
1390 |
message => $Mail::Sendmail::error, |
1396 |
message => "$_", |
1391 |
method => 'generic_confirm', |
1397 |
method => 'generic_confirm', |
1392 |
stage => 'draft', |
1398 |
stage => 'draft', |
1393 |
}; |
1399 |
}; |
1394 |
} |
1400 |
}; |
1395 |
} else { |
1401 |
} else { |
1396 |
die "Unknown stage, should not have happened." |
1402 |
die "Unknown stage, should not have happened." |
1397 |
} |
1403 |
} |
1398 |
- |
|
|