On 2012-02-21 2:55 PM, Tanstaafl <tan...@li...> wrote:
> Ok, applied the change, sent a test message to someone that I know who
> has vacation enabled (just to make sure normal vacations work properly),
> and got the following error:
>
> Command output: elseif should be elsif at
> /var/spool/vacation/vacation.pl line 530. ^* matches null string many
> times in regex; marked by<-- HERE in m/^*<-- HERE
> (linkedin|facebook|twitter|myspace)*/ at
> /var/spool/vacation/vacation.pl line 530.
Actually, I guess I can't read... tried another modification, and got
the same error, then noticed the explicit wording of the above...
Changed elseif to elsif, removed the *, and the error is gone.
I also just saw two more vacation messages that should not have gone
out, so I modified it a bit more - now I have:
sub check_and_clean_from_address {
my ($address) = @_;
my $logger = get_logger();
if($address =~
/^(noreply|postmaster|mailer\-daemon|listserv|majordomo|owner\-|request\-|bounces\-)/i
||
$address =~ /\-(owner|request|bounce|bounces)\@/i ) {
$logger->debug("sender $address contains $1 - will not send
vacation message");
exit(0);
}
elsif($address =
/^(bounce|facebook|linkedin|mediapost|myspace|twitter)/i) {
$logger->debug("sender $address contains $1 - will not send
vacation message");
exit(0);
}
$address = strip_address($address);
if($address eq "") {
$logger->error("Address $address is not valid; exiting");
exit(0);
}
#$logger->debug("Address cleaned up to $address");
return $address;
}
But I have one more question that may simplify this a lot...
If I wanted to not send a vacation message for anything that had any of
these strings *anywhere* in the envelope sender address (ie, I didn't
care about testing the localpart and host part individually), and I
didn't care about differentiating the hyphenated versions of some of
these, couldn't I simply modify the above to:
sub check_and_clean_from_address {
my ($address) = @_;
my $logger = get_logger();
if($address =
/^(bounce|daemon|facebook|linkedin|listserv|mailer|majordomo|mediapost|myspace|noreply|owner|postmaster|request|twitter)/i)
{
$logger->debug("sender $address contains $1 - will not send
vacation message");
exit(0);
}
$address = strip_address($address);
if($address eq "") {
$logger->error("Address $address is not valid; exiting");
exit(0);
}
#$logger->debug("Address cleaned up to $address");
return $address;
}
?
This looks much simpler, and will be much easier to add new strings to...
Thanks again David... this will be very helpful...
|