plugin check_badmailfrom_pattern
[email protected] (Aleksandar Lazic)
| Newsgroups | perl.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
Dear list members, today I have seen im my logs the following mail from pattern. ### [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] ### I have decided to dublicate the check_badrcptto_patterns to check_badmailfrom_pattern. I want to share with you this solution, maybe somone have the same problem but another solution ;-) The plugin checks the badrcptto_patterns file witch have the same syntax as the badrcptto_patterns. I have add the follwoing pattern into the file ### ^\d\- DENY badmailfrom_patterns ### Cheers Aleks
check_badmailfrom_pattern
(text/plain, 1.5 KB)
=pod =head1 SYNOPSIS This plugin checks the badmailfrom_patterns config. This allows special patterns to be denied (e.g. percent hack, bangs, double ats). =head1 CONFIG config/badmailfrom_patterns Patterns are stored in the format pattern\sresponse, where pattern is a Perl pattern expression. Don't forget to anchor the pattern if you want to restrict it from matching anywhere in the string. qpsmtpd already ensures that the address contains an @, with something to the left and right of the @. =head1 AUTHOR Copyright 2005 Gordon Rowell <[email protected]> Copyright 2010 Aleksandar Lazic <[email protected]> This software is free software and may be distributed under the same terms as qpsmtpd itself. =cut sub hook_mail { my ($self, $transaction, $sender, %param) = @_; my @badmailfrom = $self->qp->config("badmailfrom_patterns") or return (DECLINED); return (DECLINED) unless ($sender->format ne "<>" and $sender->host && $sender->user); my $host = lc $sender->host; my $from = lc($sender->user) . '@' . $host; for (@badmailfrom) { my ($pattern, $response) = split /\s+/, $_, 2; #return (DENY, $response) if ($to =~ /$pattern/); $transaction->notes('badmailfrom_pattern', $response) if ($from =~ /$pattern/); } return (DECLINED); } sub hook_rcpt { my ($self, $transaction, $rcpt, %param) = @_; my $note = $transaction->notes('badmailfrom_pattern'); if ($note) { $self->log(LOGINFO, $note); return (DENY, $note); } return (DECLINED); }