Lines 414-420
sub SendAlerts {
Link Here
|
414 |
my $alerts = getalert( '', 'issue', $subscriptionid ); |
414 |
my $alerts = getalert( '', 'issue', $subscriptionid ); |
415 |
foreach (@$alerts) { |
415 |
foreach (@$alerts) { |
416 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
416 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
417 |
my $email = $borinfo->{email} or next; |
417 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
|
|
418 |
my $email = $sendAllEmailsTo; |
419 |
if (!($sendAllEmailsTo && $sendAllEmailsTo =~ /@/) ){ # some validation. This could be improved. |
420 |
$email = $borinfo->{email} or next; |
421 |
} |
418 |
|
422 |
|
419 |
# warn "sending issues..."; |
423 |
# warn "sending issues..."; |
420 |
my $userenv = C4::Context->userenv; |
424 |
my $userenv = C4::Context->userenv; |
Lines 528-537
sub SendAlerts {
Link Here
|
528 |
# Remove the order tag |
532 |
# Remove the order tag |
529 |
$letter->{content} =~ s/<order>(.*?)<\/order>/$1/gxms; |
533 |
$letter->{content} =~ s/<order>(.*?)<\/order>/$1/gxms; |
530 |
|
534 |
|
|
|
535 |
# SendAllEmailsTo system preference to override for testing |
536 |
my $emailsTo = join( ',', @email); |
537 |
my $emailsCC = join( ',', @cc); |
538 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
539 |
# some validation. This could be improved. |
540 |
if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ) { |
541 |
$emailsTo = $sendAllEmailsTo; |
542 |
$emailsCC = ''; |
543 |
} |
544 |
|
531 |
# ... then send mail |
545 |
# ... then send mail |
532 |
my %mail = ( |
546 |
my %mail = ( |
533 |
To => join( ',', @email), |
547 |
To => $emailsTo, |
534 |
Cc => join( ',', @cc), |
548 |
Cc => $emailsCC, |
535 |
From => $userenv->{emailaddress}, |
549 |
From => $userenv->{emailaddress}, |
536 |
Subject => Encode::encode( "UTF-8", "" . $letter->{title} ), |
550 |
Subject => Encode::encode( "UTF-8", "" . $letter->{title} ), |
537 |
Message => $letter->{'is_html'} |
551 |
Message => $letter->{'is_html'} |
Lines 583-591
sub SendAlerts {
Link Here
|
583 |
) or return; |
597 |
) or return; |
584 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
598 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
585 |
my $email = Koha::Email->new(); |
599 |
my $email = Koha::Email->new(); |
|
|
600 |
my $emailaddr = $externalid->{'emailaddr'}; |
601 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
602 |
$emailaddr = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
586 |
my %mail = $email->create_message_headers( |
603 |
my %mail = $email->create_message_headers( |
587 |
{ |
604 |
{ |
588 |
to => $externalid->{'emailaddr'}, |
605 |
to => $emailaddr, |
589 |
from => $branchdetails->{'branchemail'}, |
606 |
from => $branchdetails->{'branchemail'}, |
590 |
replyto => $branchdetails->{'branchreplyto'}, |
607 |
replyto => $branchdetails->{'branchreplyto'}, |
591 |
sender => $branchdetails->{'branchreturnpath'}, |
608 |
sender => $branchdetails->{'branchreturnpath'}, |
Lines 1171-1176
sub _send_message_by_email {
Link Here
|
1171 |
|
1188 |
|
1172 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1189 |
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} ); |
1173 |
my $to_address = $message->{'to_address'}; |
1190 |
my $to_address = $message->{'to_address'}; |
|
|
1191 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
1192 |
$to_address = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
1174 |
unless ($to_address) { |
1193 |
unless ($to_address) { |
1175 |
unless ($member) { |
1194 |
unless ($member) { |
1176 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1195 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |