Skip to content

Commit

Permalink
Add support for a Must-Autoreply-Regexp header for autoreplies
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Aug 20, 2015
1 parent 926f35e commit 0301c47
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions sendmail/autoreply.pl
Expand Up @@ -118,6 +118,9 @@
if ($1 eq "No-Autoreply-Regexp") {
push(@no_regexp, $2);
}
elsif ($1 eq "Must-Autoreply-Regexp") {
push(@must_regexp, $2);
}
elsif ($1 eq "Autoreply-File") {
push(@files, $2);
}
Expand Down Expand Up @@ -199,11 +202,25 @@
delete($rheader{'No-Autoreply'});
}

# Check if message matches one of the deny regexps
# Check if message matches one of the deny regexps, or doesn't match a
# required regexp
foreach $re (@no_regexp) {
if ($re =~ /\S/ && $rheaders =~ /$re/i) {
if ($re =~ /\S/ && $headers =~ /$re/i) {
print STDERR "Skipping due to match on $re\n";
exit(1);
exit(0);
}
}
if (@must_regexp) {
my $found = 0;
foreach $re (@must_regexp) {
if ($headers =~ /$re/i) {
$found++;
}
}
if (!$found) {
print STDERR "Skipping due to no match on ",
join(" ", @must_regexp),"\n";
exit(0);
}
}

Expand Down

0 comments on commit 0301c47

Please sign in to comment.