Log-Fine
view release on metacpan or search on metacpan
lib/Log/Fine/Handle/Email.pm view on Meta::CPAN
and $self->_isValid($envelope->{to}));
}
# Check envelope from
if (defined $envelope->{from} and $envelope->{from} =~ /\w/) {
$self->_fatal("{envelope}->{from} must be a " . "valid RFC 822 Email Address")
unless $self->_isValid($envelope->{from});
} else {
$envelope->{from} = $self->{header_from};
}
# Validate subject formatter
$self->_fatal("{subject_formatter} must be a valid " . "Log::Fine::Formatter object")
unless (defined $self->{subject_formatter}
and $self->{subject_formatter}->isa("Log::Fine::Formatter"));
# Validate body formatter
$self->_fatal(
"{body_formatter} must be a valid " . "Log::Fine::Formatter object : " . ref $self->{body_formatter}
|| "{undef}")
unless (defined $self->{body_formatter}
and $self->{body_formatter}->isa("Log::Fine::Formatter"));
return $self;
} # _init()
##
# Getter/Setter for hostname
sub _hostName
{
my $self = shift;
# Should {_fullHost} be already cached, then return it,
# otherwise get hostname, cache it, and return
$self->{_fullHost} = hostname() || "{undef}"
unless (defined $self->{_fullHost} and $self->{_fullHost} =~ /\w/);
return $self->{_fullHost};
} # _hostName()
##
# Getter/Setter for user name
sub _userName
{
my $self = shift;
# Should {_userName} be already cached, then return it,
# otherwise get the user name, cache it, and return
if (defined $self->{_userName} and $self->{_userName} =~ /\w/) {
return $self->{_userName};
} elsif ($self->{use_effective_id}) {
$self->{_userName} =
($^O eq "MSWin32")
? $ENV{EUID} || 0
: getpwuid($>) || "nobody";
} else {
$self->{_userName} = getlogin() || getpwuid($<) || "nobody";
}
return $self->{_userName};
} # _userName()
##
# Default email address checker
#
# Parameters:
#
# - addy : either a scalar containing a string to check or an array
# ref containing one or more strings to check
#
# Returns:
#
# 1 on success, undef otherwise
sub _validate_default
{
my $self = shift;
my $addy = shift;
if (ref $addy eq "ARRAY") {
foreach my $address (@{$addy}) {
return undef
unless $address =~
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+\@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
}
} else {
return undef
unless ($addy =~
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+\@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
);
}
return 1;
} # _validate_default()
##
# Validate email address via Email::Valid
#
# Parameters:
#
# - addy : either a scalar containing a string to check or an array
# ref containing one or more strings to check
#
# Returns:
#
# 1 on success, undef otherwise
sub _validate_email_valid
{
my $self = shift;
my $addy = shift;
my $validator = Email::Valid->new();
( run in 0.541 second using v1.01-cache-2.11-cpan-0b5f733616e )