On Fri, 01 Feb 2008 12:26:40 +0100
Ulrich Stärk <[EMAIL PROTECTED]> wrote:
> I want to redirect spam (mail with X-Spam-Flag: YES) to a users spam 
> folder after the spamassassin plugin has run.
> My system is an imap setup where users can post mail to submailboxes by 
> appending +<mailboxname> to their email address, e.g. [EMAIL PROTECTED] 
> would go to INBOX.spam for the user foo.
> I'd like to have a plugin that can redirect spam to 
> <userpart>+spam@<domainpart>.
> The handler plugin (http://www.openfusion.com.au/labs/qpsmtpd/handler) 
> is capable of redirecting mail to another mailbox based on the users 
> name, e.g. "redirect_recipient -spam" would deliver spam mail to 
> <userpart>-spam@<domainpart> but it is not capable of delimiting 
> <userpart> and the spam submailbox with '+'.
> Before I go and patch the handle plugin by hand I wanted to ask if there 
> is a plugin which supports my needs.

Something like this should do:

sub hook_queue_pre {
    my ($self,$transaction) = @_;
    my @flag = $transaction->header->get("X-Spam-Flag");
    return (DECLINED) unless (lc $flag[0] eq 'yes');
    my $user;
    foreach my $addr ($transaction->recipients) {
       ($user = $addr->user) =~ s/^([^+]+)\+.+$/$1/;
       $addr->user($user."+spam");
    }
    return(DECLINED);
}

Reply via email to