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