On Wed, Jan 18, 2006 at 06:14:51PM +0100, Johan Almqvist wrote: >Here's my first own plugin. I'd be grateful for any hints on the >coding style etc. > >What it does: It will only accept messages with an envelope sender of ><> if the recipient is listed in the acceptbounce config file (or >if that file doesn't exist, to protect from configuration errors >etc). You can either add local parts or full addresses to the >acceptbounce file (mine contains: >postmaster >abuse >webmaster >and my own e-mail >)
I like this idea but it would be more useful for me if this took regexes rather than exact strings. Although, actually, hmm. I would want to be able to somehow say something like "deny bounces to everything but...". That would allow ezmlm's automatic unsubscribe to work while blocking spam bounces to everybody else. I guess that would involve a more complicated config file syntax, though. cgf >--- snipsnap --- > >sub hook_mail { > my ($self, $transaction, $sender) = @_; > > return (DECLINED) unless ($sender->format eq "<>"); > > $self->log(LOGDEBUG, "sender is <>"); > $transaction->notes('bounce',1); > > return (DECLINED); >} > >sub hook_rcpt { > my ($self, $transaction, $rcpt) = @_; > my $note = $transaction->notes('bounce'); > return DECLINED unless $note; > > my @acceptbounce = $self->qp->config("acceptbounce"); > return DECLINED unless (@acceptbounce); > # Can't do this on one line becuase config is dependent on wantarray > > my $user = lc($rcpt->user); > my $addr = $user . '@' . lc($rcpt->host); > > foreach my $to (@acceptbounce) { > chomp $to; > return DECLINED if ($user eq $to); > return DECLINED if ($addr eq $to); > } > $self->log(LOGDEBUG, "not accepting bounces for $addr"); > return (DENY, "sorry, this address never sends mail ". > "and therefore does not accept bounces"); >} >