|
Lines 294-299
sub DelLetter {
Link Here
|
| 294 |
sub SendAlerts { |
294 |
sub SendAlerts { |
| 295 |
my ( $type, $externalid, $letter_code ) = @_; |
295 |
my ( $type, $externalid, $letter_code ) = @_; |
| 296 |
my $dbh = C4::Context->dbh; |
296 |
my $dbh = C4::Context->dbh; |
|
|
297 |
my $error; |
| 298 |
|
| 297 |
if ( $type eq 'issue' ) { |
299 |
if ( $type eq 'issue' ) { |
| 298 |
|
300 |
|
| 299 |
# prepare the letter... |
301 |
# prepare the letter... |
|
Lines 357-369
sub SendAlerts {
Link Here
|
| 357 |
$mail->text_body( $letter->{content} ); |
359 |
$mail->text_body( $letter->{content} ); |
| 358 |
} |
360 |
} |
| 359 |
|
361 |
|
| 360 |
try { |
362 |
my $success = try { |
| 361 |
$mail->send_or_die({ transport => $library->smtp_server->transport }); |
363 |
$mail->send_or_die({ transport => $library->smtp_server->transport }); |
| 362 |
} |
364 |
} |
| 363 |
catch { |
365 |
catch { |
|
|
366 |
# We expect ref($_) eq 'Email::Sender::Failure' |
| 367 |
$error = $_->message; |
| 368 |
|
| 364 |
carp "$_"; |
369 |
carp "$_"; |
| 365 |
return { error => "$_" }; |
370 |
return; |
| 366 |
}; |
371 |
}; |
|
|
372 |
|
| 373 |
return { error => $error } |
| 374 |
unless $success; |
| 367 |
} |
375 |
} |
| 368 |
} |
376 |
} |
| 369 |
elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' or $type eq 'orderacquisition' ) { |
377 |
elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' or $type eq 'orderacquisition' ) { |
|
Lines 511-524
sub SendAlerts {
Link Here
|
| 511 |
$mail->text_body( "" . $letter->{content} ); |
519 |
$mail->text_body( "" . $letter->{content} ); |
| 512 |
} |
520 |
} |
| 513 |
|
521 |
|
| 514 |
try { |
522 |
my $success = try { |
| 515 |
$mail->send_or_die({ transport => $library->smtp_server->transport }); |
523 |
$mail->send_or_die({ transport => $library->smtp_server->transport }); |
| 516 |
} |
524 |
} |
| 517 |
catch { |
525 |
catch { |
|
|
526 |
# We expect ref($_) eq 'Email::Sender::Failure' |
| 527 |
$error = $_->message; |
| 528 |
|
| 518 |
carp "$_"; |
529 |
carp "$_"; |
| 519 |
return { error => "$_" }; |
530 |
return; |
| 520 |
}; |
531 |
}; |
| 521 |
|
532 |
|
|
|
533 |
return { error => $error } |
| 534 |
unless $success; |
| 535 |
|
| 522 |
logaction( |
536 |
logaction( |
| 523 |
"ACQUISITION", |
537 |
"ACQUISITION", |
| 524 |
$action, |
538 |
$action, |
|
Lines 547-553
sub SendAlerts {
Link Here
|
| 547 |
want_librarian => 1, |
561 |
want_librarian => 1, |
| 548 |
) or return; |
562 |
) or return; |
| 549 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
563 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
| 550 |
try { |
564 |
|
|
|
565 |
my $success = try { |
| 551 |
|
566 |
|
| 552 |
# FIXME: This 'default' behaviour should be moved to Koha::Email |
567 |
# FIXME: This 'default' behaviour should be moved to Koha::Email |
| 553 |
my $mail = Koha::Email->create( |
568 |
my $mail = Koha::Email->create( |
|
Lines 570-578
sub SendAlerts {
Link Here
|
| 570 |
$mail->send_or_die({ transport => $library->smtp_server->transport }); |
585 |
$mail->send_or_die({ transport => $library->smtp_server->transport }); |
| 571 |
} |
586 |
} |
| 572 |
catch { |
587 |
catch { |
|
|
588 |
# We expect ref($_) eq 'Email::Sender::Failure' |
| 589 |
$error = $_->message; |
| 590 |
|
| 573 |
carp "$_"; |
591 |
carp "$_"; |
| 574 |
return { error => "$_" }; |
592 |
return; |
| 575 |
}; |
593 |
}; |
|
|
594 |
|
| 595 |
return { error => $error } |
| 596 |
unless $success; |
| 576 |
} |
597 |
} |
| 577 |
|
598 |
|
| 578 |
# If we come here, return an OK status |
599 |
# If we come here, return an OK status |
| 579 |
- |
|
|