Lines 403-409
sub SendAlerts {
Link Here
|
403 |
my $alerts = getalert( '', 'issue', $externalid ); |
403 |
my $alerts = getalert( '', 'issue', $externalid ); |
404 |
foreach (@$alerts) { |
404 |
foreach (@$alerts) { |
405 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
405 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
406 |
my $email = $borinfo->{email} or next; |
406 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
|
|
407 |
my $email = $sendAllEmailsTo; |
408 |
if (!($sendAllEmailsTo && $sendAllEmailsTo =~ /@/) ){ # some validation. This could be improved. |
409 |
$email = $borinfo->{email} or next; |
410 |
} |
407 |
|
411 |
|
408 |
# warn "sending issues..."; |
412 |
# warn "sending issues..."; |
409 |
my $userenv = C4::Context->userenv; |
413 |
my $userenv = C4::Context->userenv; |
Lines 515-524
sub SendAlerts {
Link Here
|
515 |
# Remove the order tag |
519 |
# Remove the order tag |
516 |
$letter->{content} =~ s/<order>(.*?)<\/order>/$1/gxms; |
520 |
$letter->{content} =~ s/<order>(.*?)<\/order>/$1/gxms; |
517 |
|
521 |
|
|
|
522 |
# SendAllEmailsTo system preference to override for testing |
523 |
my $emailsTo = join( ',', @email); |
524 |
my $emailsCC = join( ',', @cc); |
525 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
526 |
# some validation. This could be improved. |
527 |
if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ) { |
528 |
$emailsTo = $sendAllEmailsTo; |
529 |
$emailsCC = ''; |
530 |
} |
531 |
|
518 |
# ... then send mail |
532 |
# ... then send mail |
519 |
my %mail = ( |
533 |
my %mail = ( |
520 |
To => join( ',', @email), |
534 |
To => $emailsTo, |
521 |
Cc => join( ',', @cc), |
535 |
Cc => $emailsCC, |
522 |
From => $userenv->{emailaddress}, |
536 |
From => $userenv->{emailaddress}, |
523 |
Subject => Encode::encode( "UTF-8", "" . $letter->{title} ), |
537 |
Subject => Encode::encode( "UTF-8", "" . $letter->{title} ), |
524 |
Message => $letter->{'is_html'} |
538 |
Message => $letter->{'is_html'} |
Lines 568-576
sub SendAlerts {
Link Here
|
568 |
) or return; |
582 |
) or return; |
569 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
583 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
570 |
my $email = Koha::Email->new(); |
584 |
my $email = Koha::Email->new(); |
|
|
585 |
my $emailaddr = $externalid->{'emailaddr'}; |
586 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
587 |
$emailaddr = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
571 |
my %mail = $email->create_message_headers( |
588 |
my %mail = $email->create_message_headers( |
572 |
{ |
589 |
{ |
573 |
to => $externalid->{'emailaddr'}, |
590 |
to => $emailaddr, |
574 |
from => $branchdetails->{'branchemail'}, |
591 |
from => $branchdetails->{'branchemail'}, |
575 |
replyto => $branchdetails->{'branchreplyto'}, |
592 |
replyto => $branchdetails->{'branchreplyto'}, |
576 |
sender => $branchdetails->{'branchreturnpath'}, |
593 |
sender => $branchdetails->{'branchreturnpath'}, |
Lines 1128-1133
sub _send_message_by_email {
Link Here
|
1128 |
|
1145 |
|
1129 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1146 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1130 |
my $to_address = $message->{'to_address'}; |
1147 |
my $to_address = $message->{'to_address'}; |
|
|
1148 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
1149 |
$to_address = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
1131 |
unless ($to_address) { |
1150 |
unless ($to_address) { |
1132 |
unless ($member) { |
1151 |
unless ($member) { |
1133 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1152 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |