@@ -, +, @@ Email::Valid . --- C4/Letters.pm | 2 +- basket/sendbasket.pl | 3 ++- misc/cronjobs/runreport.pl | 3 ++- opac/opac-sendbasket.pl | 3 ++- opac/opac-sendshelf.pl | 3 ++- virtualshelves/sendshelf.pl | 3 ++- 6 files changed, 11 insertions(+), 6 deletions(-) --- a/C4/Letters.pm +++ a/C4/Letters.pm @@ -524,7 +524,7 @@ sub SendAlerts { my $emailsTo = join( ',', @email); my $emailsCC = join( ',', @cc); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); - # some validation. This could be improved. + if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ) { $emailsTo = $sendAllEmailsTo; $emailsCC = ''; --- a/basket/sendbasket.pl +++ a/basket/sendbasket.pl @@ -31,6 +31,7 @@ use C4::Auth; use C4::Output; use C4::Biblio; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -47,7 +48,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $bib_list = $query->param('bib_list'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email_add = $query->param('email_add'); -$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); my $email_sender = $query->param('email_sender'); my $dbh = C4::Context->dbh; --- a/misc/cronjobs/runreport.pl +++ a/misc/cronjobs/runreport.pl @@ -33,6 +33,7 @@ use Text::CSV_XS; use CGI qw ( -utf8 ); use Carp; use Encode; +use Email::Valid; use vars qw($VERSION); @@ -208,7 +209,7 @@ if ($to or $from or $email) { $to or $to = C4::Context->preference('KohaAdminEmailAddress'); } my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); -$to = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$to = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); unless (scalar(@ARGV)) { print STDERR "ERROR: No reportID(s) specified\n"; --- a/opac/opac-sendbasket.pl +++ a/opac/opac-sendbasket.pl @@ -34,6 +34,7 @@ use C4::Output; use C4::Biblio; use C4::Members; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -50,7 +51,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $bib_list = $query->param('bib_list'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email_add = $query->param('email_add'); -$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email_add = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); my $email_sender = $query->param('email_sender'); my $dbh = C4::Context->dbh; --- a/opac/opac-sendshelf.pl +++ a/opac/opac-sendshelf.pl @@ -34,6 +34,7 @@ use C4::Output; use C4::VirtualShelves; use C4::Members; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -50,7 +51,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( my $shelfid = $query->param('shelfid'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email = $query->param('email'); -$email = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); my $dbh = C4::Context->dbh; --- a/virtualshelves/sendshelf.pl +++ a/virtualshelves/sendshelf.pl @@ -33,6 +33,7 @@ use C4::Items; use C4::Output; use C4::VirtualShelves; use Koha::Email; +use Email::Valid; my $query = new CGI; @@ -49,7 +50,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $shelfid = $query->param('shelfid'); my $sendAllEmailsTo = C4::Context->preference('SendAllEmailsTo'); my $email = $query->param('email'); -$email = $sendAllEmailsTo if ($sendAllEmailsTo && $sendAllEmailsTo =~ /@/ ); # some validation. This could be improved. +$email = $sendAllEmailsTo if ($sendAllEmailsTo && Email::Valid->address($sendAllEmailsTo) ); my $dbh = C4::Context->dbh; --