Filtering spam to an IMAP folder with postfix, policyd and amavis?

177

Solution 1

There are several options to accomplish this, and they all largely depend on the delivery agent you are using to do the final delivery to a user's virtual mailbox.

  1. If you are using the stock Postfix virtual(8) delivery agent, you can't accomplish this.
  2. If you are using either the Cyrus LDA or the Dovecot LDA, you habe two more options: You can either use their builtin Sieve functionality (a quick Google search should reveal how to parse the X-Spam-Status header) and provide a global Sieve script or make use of recipient delimiters (set recipient_delimiter = + in Postfix' main.cf and have a look at the redirect documentation for amavisd-new).
  3. If you are using maildrop, see James' answer.
  4. If none of this options are applicable, you could let amavisd-new put those mails to a quarantine. OSS quarantine managers are scarce, for SQL based quarantine I do only know of MailZu and MailZu-ng for modern amavisd-new. Maia Mailguard comes with it's own amavisd-new implementation (I don't recommend using Maia for various reasons). Finally, I've lately been writing a combined quarantine/mailsettings management application, but I can't give any dates on when this one will be finished).

A wholly different approach, given that either your mail volume is low or you have access to some serious hardware, would be to run amavisd-new as a before queue filter, thereby eleminating the need for spam/junk folders or quarantine completely: If a legitimate mail is rejected as spam, the sender will be notified by it's own mail server - since you technically never accepted the mail, you won't be responsible for anything.

Solution 2

You'll need to setup something like procmail or maildrop to filter the mail into the correct folder when it gets delivered.

Using maildrop you can have a default system wide config which will check the headers and filter spam into the correct location, with something like this in /etc/maildroprc:

if (/^X-Spam-Status: yes) {
    to "Maildir/.Spam"
}

change the mailbox location depending on your local setup.

Share:
177

Related videos on Youtube

paragbaxi
Author by

paragbaxi

Updated on September 17, 2022

Comments

  • paragbaxi
    paragbaxi almost 2 years

    Is it possible to call the "Email This Issue" method (url shows "com.metainf.jira.plugin.emailissue.action.EmailThisIssue") from SOAP? I would like to email this issue to the assignee with a custom description.

  • user1902602
    user1902602 about 14 years
    Could I ask why you don't recommend Maia? (I'm a developer for Maia)