develooper Front page | perl.qpsmtpd.dev | Postings from July 2010

Re: [PATCH 1/3] Created a missing plugin

Thread Previous | Thread Next
From:
Robert Spier
Date:
July 10, 2010 21:36
Subject:
Re: [PATCH 1/3] Created a missing plugin
Message ID:
87bpaeiqit.wl_rs@pobox.com

Johan-

  Since this is a proposed new plugin, it might be easier just to
  attach the full file.  It's also possible to convince git to mail
  this as one thing...

  Please include some example config in the plugin, so it is more
  obvious how to use it.

  Also, don't you need to rename the file?

-R

johan-qpsmtpd@almqvist.net wrote:
> 
> From: Johan Almqvist <johan@almqvist.net>
> 
> diff --git a/plugins/check_badmailfrom_patterns b/plugins/check_badmailfrom_patterns
> new file mode 100644
> index 0000000..accffd8
> --- /dev/null
> +++ b/plugins/check_badmailfrom_patterns
> @@ -0,0 +1,54 @@
> +=pod
> +
> +=head1 SYNOPSIS
> +
> +This plugin checks the badmailto_patterns config. This allows
> +special patterns to be denied (e.g. percent hack, bangs,
> +double ats).
> +
> +=head1 CONFIG
> +
> +config/badmailto_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.
> +
> +=head1 AUTHOR
> +
> +Copyright 2009 Johan Almqvist <johan-qpsmtpd@almqvist.net>
> +
> +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) if ($sender->format eq "<>");
> +
> +  my $host = lc $sender->host;
> +  my $from = lc($sender->user) . '@' . $host;
> +
> +  for (@badmailfrom) {
> +    my ($pattern, $response) = split /\s+/, $_, 2;
> +    $response = "Your envelope sender is in my badmailfrom list" unless $response;
> +    $transaction->notes('badmailfrom_patterns', $response) if ($from =~ /$pattern/);
> +  }
> +  return (DECLINED);
> +}
> +
> +sub hook_rcpt
> +{
> +  my ($self, $transaction, $rcpt, %param) = @_;
> +  my $note = $transaction->notes('badmailfrom_patterns');
> +  if ($note) {
> +    $self->log(LOGINFO, $note);
> +    return (DENY, $note);
> +  }
> +  return (DECLINED);
> +}
> \ No newline at end of file
> -- 
> 1.4.4.4
> 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About