Lines 20-26
package Koha::Email;
Link Here
|
20 |
|
20 |
|
21 |
use Modern::Perl; |
21 |
use Modern::Perl; |
22 |
|
22 |
|
23 |
use Email::Valid; |
23 |
use Email::Address; |
24 |
use Email::MessageID; |
24 |
use Email::MessageID; |
25 |
use List::Util qw(pairs); |
25 |
use List::Util qw(pairs); |
26 |
|
26 |
|
Lines 78-84
sub create {
Link Here
|
78 |
my $args = {}; |
78 |
my $args = {}; |
79 |
$args->{from} = $params->{from} || C4::Context->preference('KohaAdminEmailAddress'); |
79 |
$args->{from} = $params->{from} || C4::Context->preference('KohaAdminEmailAddress'); |
80 |
Koha::Exceptions::BadParameter->throw("Invalid 'from' parameter: ".$args->{from}) |
80 |
Koha::Exceptions::BadParameter->throw("Invalid 'from' parameter: ".$args->{from}) |
81 |
unless Email::Valid->address( -address => $args->{from}, -fqdn => 0 ); # from is mandatory |
81 |
unless $args->{from} =~ m/$Email::Address::mailbox/; # from is mandatory |
82 |
|
82 |
|
83 |
$args->{subject} = $params->{subject} // ''; |
83 |
$args->{subject} = $params->{subject} // ''; |
84 |
|
84 |
|
Lines 90-96
sub create {
Link Here
|
90 |
} |
90 |
} |
91 |
|
91 |
|
92 |
Koha::Exceptions::BadParameter->throw("Invalid 'to' parameter: ".$args->{to}) |
92 |
Koha::Exceptions::BadParameter->throw("Invalid 'to' parameter: ".$args->{to}) |
93 |
unless Email::Valid->address( -address => $args->{to}, -fqdn => 0 ); # to is mandatory |
93 |
unless $args->{to} =~ m/$Email::Address::mailbox/; # to is mandatory |
94 |
|
94 |
|
95 |
my $addresses = {}; |
95 |
my $addresses = {}; |
96 |
$addresses->{reply_to} = $params->{reply_to}; |
96 |
$addresses->{reply_to} = $params->{reply_to}; |
Lines 111-120
sub create {
Link Here
|
111 |
foreach my $address ( keys %{$addresses} ) { |
111 |
foreach my $address ( keys %{$addresses} ) { |
112 |
Koha::Exceptions::BadParameter->throw( |
112 |
Koha::Exceptions::BadParameter->throw( |
113 |
"Invalid '$address' parameter: " . $addresses->{$address} ) |
113 |
"Invalid '$address' parameter: " . $addresses->{$address} ) |
114 |
if $addresses->{$address} and !Email::Valid->address( |
114 |
if $addresses->{$address} |
115 |
-address => $addresses->{$address}, |
115 |
and $addresses->{$address} !~ m/$Email::Address::mailbox/; |
116 |
-fqdn => 0 |
|
|
117 |
); |
118 |
} |
116 |
} |
119 |
|
117 |
|
120 |
$args->{cc} = $addresses->{cc} |
118 |
$args->{cc} = $addresses->{cc} |
121 |
- |
|
|