Adding user filters
From Veximwiki
Just a small note for others trying to do the same:
I needed a user filter on a couple of mailboxes to do some more advanced filtering and so for reference, here are a couple of changes to your Exim config that will give you the ability.
Setting it up
First create a "filter" field in your users table (a mediumtext should suffice).
Remove the "directory = " option on the virtual_domains transport, as far as I can tell, it's superfluous here as the path is set via the redirect routers.
Add this redirect router immediately above your virtual_domains router:
virtual_domains_filters:
driver = redirect
allow_filter
data = ${lookup mysql{select filter from users,domains \
where localpart = '${quote_mysql:$local_part}' \
and domain = '${quote_mysql:$domain}' \
and domains.enabled = '1' \
and users.enabled = '1' \
and users.domain_id = domains.domain_id}}
router_home_directory = ${lookup mysql{select smtp from users,domains \
where localpart = '${quote_mysql:$local_part}' \
and domain = '${quote_mysql:$domain}' \
and domains.enabled = '1' \
and users.enabled = '1' \
and users.domain_id = domains.domain_id}}
user = ${lookup mysql{select users.uid from users,domains \
where localpart = '${quote_mysql:$local_part}' \
and domain = '${quote_mysql:$domain}' \
and users.domain_id = domains.domain_id}}
group = ${lookup mysql{select users.gid from users,domains \
where localpart = '${quote_mysql:$local_part}' \
and domain = '${quote_mysql:$domain}' \
and users.domain_id = domains.domain_id}}
local_part_suffix = +*
local_part_suffix_optional
retry_use_local_part
file_transport = virtual_delivery
reply_transport = address_reply
pipe_transport = address_pipe
You may want to remove the pipe_transport if you want to disable that ability.
That should then enable the use of any type of filter in the user entry in the DB, along with $home being set to the user's mail path. Normal delivery would then be to $home.
Filter documentation: http://www.exim.org/exim-html-current/doc/html/filter.html
Management of filters
I haven't given the ability to users to edit their own filters directly for security reasons (allowing them to pipe and save mail to anywhere allowed by a shared UID/GID, would be better if they had their own).
If you do want to give the ability to users to edit their own filters, then it could either be integrated into the web interface and/or a managesieve daemon. pysieved looks like it should be fairly easy to integrate, just needs another module written for it, which I may do soon to integrate it into another site.
--Dominic 17:08, 23 June 2007 (PDT)
