Lines 284-290
sub SendAlerts {
Link Here
|
284 |
foreach (@$alerts) { |
284 |
foreach (@$alerts) { |
285 |
|
285 |
|
286 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
286 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
287 |
my $email = $borinfo->{email} or next; |
287 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
|
|
288 |
my $email = $sendAllEmailsTo; |
289 |
if (!($sendAllEmailsTo && $sendAllEmailsTo =~ /@/) ){ # some validation. This could be improved. |
290 |
$email = $borinfo->{email} or next; |
291 |
} |
288 |
|
292 |
|
289 |
# warn "sending issues..."; |
293 |
# warn "sending issues..."; |
290 |
my $userenv = C4::Context->userenv; |
294 |
my $userenv = C4::Context->userenv; |
Lines 368-376
sub SendAlerts {
Link Here
|
368 |
want_librarian => 1, |
372 |
want_librarian => 1, |
369 |
) or return; |
373 |
) or return; |
370 |
|
374 |
|
|
|
375 |
my $allemails = join( ',', @email); |
376 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
377 |
$allemails = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
371 |
# ... then send mail |
378 |
# ... then send mail |
372 |
my %mail = ( |
379 |
my %mail = ( |
373 |
To => join( ',', @email), |
380 |
To => $allemails, |
374 |
From => $userenv->{emailaddress}, |
381 |
From => $userenv->{emailaddress}, |
375 |
Subject => Encode::encode( "utf8", "" . $letter->{title} ), |
382 |
Subject => Encode::encode( "utf8", "" . $letter->{title} ), |
376 |
Message => Encode::encode( "utf8", "" . $letter->{content} ), |
383 |
Message => Encode::encode( "utf8", "" . $letter->{content} ), |
Lines 406-413
sub SendAlerts {
Link Here
|
406 |
) or return; |
413 |
) or return; |
407 |
|
414 |
|
408 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
415 |
return { error => "no_email" } unless $externalid->{'emailaddr'}; |
|
|
416 |
my $emailaddr = $externalid->{'emailaddr'}; |
417 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
418 |
$emailaddr = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
419 |
# ... then send mail |
409 |
my %mail = ( |
420 |
my %mail = ( |
410 |
To => $externalid->{'emailaddr'}, |
421 |
To => $emailaddr, |
411 |
From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), |
422 |
From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), |
412 |
Subject => Encode::encode( "utf8", $letter->{'title'} ), |
423 |
Subject => Encode::encode( "utf8", $letter->{'title'} ), |
413 |
Message => Encode::encode( "utf8", $letter->{'content'} ), |
424 |
Message => Encode::encode( "utf8", $letter->{'content'} ), |