File: check_badrcptto_patterns

package info (click to toggle)
qpsmtpd 0.84-9
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,376 kB
  • sloc: perl: 8,012; sh: 382; makefile: 61
file content (47 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
=pod

=head1 SYNOPSIS

This plugin checks the badrcptto_patterns config. This allows
special patterns to be denied (e.g. percent hack, bangs, 
double ats).

=head1 CONFIG

config/badrcptto_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 <gordonr@gormand.com.au>

This software is free software and may be distributed under the same
terms as qpsmtpd itself.

=cut

sub hook_rcpt
{
  my ($self, $transaction, $recipient) = @_;

  return (DECLINED) if $self->qp->connection->relay_client();

  my @badrcptto = $self->qp->config("badrcptto_patterns") or return (DECLINED);
  my $host = lc $recipient->host;
  my $to = lc($recipient->user) . '@' . $host;

  for (@badrcptto)
  {
      my ($pattern, $response) = split /\s+/, $_, 2;

      return (DENY, $response) if ($to =~ /$pattern/);
  }

  return (DECLINED);
}