Lines 529-584
sub SendAlerts {
Link Here
|
529 |
. $letter->{content} |
529 |
. $letter->{content} |
530 |
) if C4::Context->preference("ClaimsLog"); |
530 |
) if C4::Context->preference("ClaimsLog"); |
531 |
} |
531 |
} |
532 |
# send an "account details" notice to a newly created user |
|
|
533 |
elsif ( $type eq 'members' ) { |
534 |
my $library = Koha::Libraries->find( $externalid->{branchcode} ); |
535 |
my $letter = GetPreparedLetter ( |
536 |
module => 'members', |
537 |
letter_code => $letter_code, |
538 |
branchcode => $externalid->{'branchcode'}, |
539 |
lang => $externalid->{lang} || 'default', |
540 |
tables => { |
541 |
'branches' => $library->unblessed, |
542 |
'borrowers' => $externalid->{'borrowernumber'}, |
543 |
}, |
544 |
substitute => { 'borrowers.password' => $externalid->{'password'} }, |
545 |
want_librarian => 1, |
546 |
) or return; |
547 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
548 |
|
549 |
my $success = try { |
550 |
|
551 |
# FIXME: This 'default' behaviour should be moved to Koha::Email |
552 |
my $mail = Koha::Email->create( |
553 |
{ |
554 |
to => $externalid->{'emailaddr'}, |
555 |
from => $library->branchemail, |
556 |
reply_to => $library->branchreplyto, |
557 |
sender => $library->branchreturnpath, |
558 |
subject => "" . $letter->{'title'}, |
559 |
} |
560 |
); |
561 |
|
562 |
if ( $letter->{is_html} ) { |
563 |
$mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) ); |
564 |
} |
565 |
else { |
566 |
$mail->text_body( $letter->{content} ); |
567 |
} |
568 |
|
569 |
$mail->send_or_die({ transport => $library->smtp_server->transport }); |
570 |
} |
571 |
catch { |
572 |
# We expect ref($_) eq 'Email::Sender::Failure' |
573 |
$error = $_->message; |
574 |
|
575 |
carp "$_"; |
576 |
return; |
577 |
}; |
578 |
|
579 |
return { error => $error } |
580 |
unless $success; |
581 |
} |
582 |
|
532 |
|
583 |
# If we come here, return an OK status |
533 |
# If we come here, return an OK status |
584 |
return 1; |
534 |
return 1; |