I have a (Linux) mail server that consists of postfix
for receiving mail, amavisd-new
for content filtering (using clamav
and SpamAssassin
), and dovecot
for delivery and IMAP.
I'd like to set things up so that a script is fired off every time an email is delivered to a particular mailbox. The script doesn't necessarily need to know anything about the content or headers of the message. I know of at least a couple of options:
Use
postfix
's built-in filtering. Set up a header check to reroute any emails destined for this mailbox to my script, which can then pass it back intopostfix
. The disadvantage here is that it all happens beforeamavis
's filtering, so my script will get fired off even for emails that end up getting blocked before delivery. There may also be performance penalities and risk of lost emails if I don't execute the passage of the email back intopostfix
properly.Add my script as a content filter to
amavis
. This may be an improvement in performance compared to the previous, and just seems like a better place for this. Unfortunately it still suffers from being executed before the go/no-go decision has been made on the message. Additionally, I've not been able to find theamavis
documentation detailing how this is actually supposed to be done, and the conf files aren't really conclusive.
Seems like the final dovecot
delivery step would be the best place to get only filtered mail, but I'm not sure if there's a way to make that work.
Suggestions? Anything I'm overlooking?
Edit: Forgot to add, I'd like to avoid polling-type solutions (watching logs, IMAP client script, etc.)