Lines 36-41
use Encode;
Link Here
|
36 |
use Carp; |
36 |
use Carp; |
37 |
use Koha::Email; |
37 |
use Koha::Email; |
38 |
use Koha::DateUtils qw( format_sqldatetime ); |
38 |
use Koha::DateUtils qw( format_sqldatetime ); |
|
|
39 |
use Data::Validate::Email qw(is_email); |
39 |
|
40 |
|
40 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
41 |
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
41 |
|
42 |
|
Lines 416-422
sub SendAlerts {
Link Here
|
416 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
417 |
my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); |
417 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
418 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
418 |
my $email = $sendAllEmailsTo; |
419 |
my $email = $sendAllEmailsTo; |
419 |
if (!($sendAllEmailsTo && $sendAllEmailsTo =~ /@/) ){ # some validation. This could be improved. |
420 |
if (!($sendAllEmailsTo && is_email($sendAllEmailsTo))){ |
420 |
$email = $borinfo->{email} or next; |
421 |
$email = $borinfo->{email} or next; |
421 |
} |
422 |
} |
422 |
|
423 |
|
Lines 537-543
sub SendAlerts {
Link Here
|
537 |
my $emailsCC = join( ',', @cc); |
538 |
my $emailsCC = join( ',', @cc); |
538 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
539 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
539 |
# some validation. This could be improved. |
540 |
# some validation. This could be improved. |
540 |
if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ) { |
541 |
if ($sendAllEmailsTo && is_email($sendAllEmailsTo) ) { |
541 |
$emailsTo = $sendAllEmailsTo; |
542 |
$emailsTo = $sendAllEmailsTo; |
542 |
$emailsCC = ''; |
543 |
$emailsCC = ''; |
543 |
} |
544 |
} |
Lines 599-605
sub SendAlerts {
Link Here
|
599 |
my $email = Koha::Email->new(); |
600 |
my $email = Koha::Email->new(); |
600 |
my $emailaddr = $externalid->{'emailaddr'}; |
601 |
my $emailaddr = $externalid->{'emailaddr'}; |
601 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
602 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
602 |
$emailaddr = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
603 |
$emailaddr = $sendAllEmailsTo if ($sendAllEmailsTo && is_email($sendAllEmailsTo) ); |
603 |
my %mail = $email->create_message_headers( |
604 |
my %mail = $email->create_message_headers( |
604 |
{ |
605 |
{ |
605 |
to => $emailaddr, |
606 |
to => $emailaddr, |
Lines 1192-1198
sub _send_message_by_email {
Link Here
|
1192 |
$to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} ); |
1193 |
$to_address = C4::Members::GetNoticeEmailAddress( $message->{'borrowernumber'} ); |
1193 |
} |
1194 |
} |
1194 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
1195 |
my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); |
1195 |
$to_address = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. |
1196 |
$to_address = $sendAllEmailsTo if ($sendAllEmailsTo && is_email($sendAllEmailsTo) ); |
1196 |
unless ($to_address) { |
1197 |
unless ($to_address) { |
1197 |
if (!$member) { |
1198 |
if (!$member) { |
1198 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1199 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1199 |
- |
|
|