Ok, I got curious and went ahead and tried this, and it seems to be
working just fine.
I tested with various strings (at the beginning, in the middle and the
end of the defined variable), and everything that should have matched,
did, and everything else produced a proper vacation response...
So, I now have the following in vacation.pl:
> # $noreply_pattern is the list of strings that is checked against both the
> # envelope sender and any/all From header addresses that, if matched,
> # results in the vacation message not being sent.
> # By default, vacation messages will be sent to all senders that can not
> # definitively be determined to be email lists or other senders that should
> # not be replied to, like messages from social networking sites.
> # Defaults are: 'bounce|do-not-reply|facebook|linkedin|list-|listserv|mailer\-daemon|majordomo|myspace|noreply|owner\-|\-(owner|request|bounces)|postmaster|request\-|twitter'
> # MODIFY AT YOUR OWN RISK!
> our $noreply_pattern = 'bounce|do-not-reply|facebook|linkedin|list-|listserv|mailer\-daemon|majordomo|myspace|noreply|owner\-|\-(owner|request|bounces)|postmaster|request\-|twitter'
then the check_and_clean_from_address function:
> # Check sender against the new configurable $noreply_pattern to make sure
> # the email wasn't sent by a mailing list or some other kind of automated
> # messaging system; if it was, then we abort after appropriate logging.
> sub check_and_clean_from_address {
> my ($address) = @_;
> my $logger = get_logger();
>
> if($address =~ /^.*($noreply_pattern).*/i) {
> $logger->debug("sender '$address' contains '$1'; will not send vacation message; aborting");
> 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;
> }
Thanks again to Rudi for doing the heavy lifting and getting this working!
Charles
On 2013-03-13 12:45 PM, Tanstaafl <tan...@li...> wrote:
> Corrections to previous post below, and also an additional question...
>
> On 2013-03-13 11:43 AM, Tanstaafl <tan...@li...> wrote:
>> 1. only ONE new variable that contains all of the predetermined strings,
>> and
>
> Sorry, sent that too soon without proofing. This should have all read:
>
> There are two advantages to this...
>
> 1. Only the new variable (with pre-determined defaults) is needed
> instead of a new option and a new variable with just a comment
> explaining how to modify this variable to include new strings or tweak
> existing ones or even remove them if they are causing too many false
> positives:,
>
> So we'd now have (which can also optionally go into vacation.conf):
>
>> # This is the list of strings that is checked against both the
>> # envelope sender and any/all From header addresses that, if
>> # matched, results in the vacation message not being sent.
> > # MODIFY AT YOUR OWN RISK!
>> our $noreply_pattern =
>> 'bounce|do-not-reply|facebook|linkedin|list-|listserv|mailer\-daemon|majordomo|myspace|noreply|owner\-|\-(owner|request|bounces)|postmaster|request\-|twitter';
>
> Then the new 'sub check_and_clean_from_address' function would be
> something like:
>
>> sub check_and_clean_from_address {
>> my ($address) = @_;
>> my $logger = get_logger();
>>
>> if($address =~ /^.*($noreply_pattern).*/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;
>> }
>>
>> And finally, last question...
>>
>> What is the practical limit on the number of characters that can be
>> included in this variable?
>
> One other question, already asked in a prior email, is...
>
> Am I correct in my comments, that BOTH the envelope sender and any other
> From headers are tested? Or does this check_and_clean_from_address
> function only test the envelope sender? If so (and I think it might),
> then we may need to have two new variables:
>
> $noreply_pattern_envelope
> $noreply_pattern_header
>
> and appropriate comment changes.
>
>> So, before I enable these changes, what do you think? If this looks
>> correct, I'll enable it and test it live for the next few weeks on my
>> server...
>>
>> Thanks again Rudi!
|