|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Magnus Bäck (magnus
dsek.lth.se)
Date: Sun Mar 02 2008 - 15:25:35 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sunday, March 02, 2008 at 10:06 CET,
Olivier Nicole <on
cs.ait.ac.th> wrote:
> I am pretty new to Postfix. I am trying to set-up a virtual server
> following the rules in
> http://howtoforge.org/virtual_postfix_mysql_quota_courier, so far it
> is working but I would like to send the spam mail into a specific
> folder.
>
> I get amavisd-new to send the mail to user+junk
domain when it is
> tested to be spam.
>
> But I don't know, don't understand how to configure Postfix to deliver
> this into ~user/.Junk instad of the normal mailbox.
Use a delivery agent capable of filtering messages into different
mailboxes depending on, for example, header or recipient address
information. Postfix' virtual(8) is not exactly filtering-enabled, but
in this particular case it's usable. As you know virtual(8) looks up the
recipient address in virtual_mailbox_maps and uses the returned mailbox
path. All you need to do is have an additional query that returns a
different address if the userpart of the address ends with +junk. You're
using MySQL so there is no need to store information twice -- construct
a query that given user+junk
example.com as input returns the same
mailbox path as user
example.com but with /.Junk tacked on at the end.
Something like this should work, assuming you store user names and
domain names in separate columns:
SELECT CONCAT(mailbox_path, '/.Junk/') FROM users
WHERE '%u' = CONCAT(user, '+junk') AND '%d' = domain
This query is probably not optimal because of the table scans it may
force, but lookup latency is probably not a bottleneck for you anyway.
If you only store complete mail addresses you'll have to resort to using
SUBSTRING and INDEX, but that's left as an exercise for the reader.
For the more general case of sorting different messages into different
folders virtual(8) won't cut it, and since you're using Courier maildrop
would be the obvious choice of such a delivery agent.
--
Magnus Bäck
magnus
dsek.lth.se
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]