[Pkg-exim4-users] filter to separate folders via dovecot
Thomas Koch
thomas at koch.ro
Sun Dec 30 11:01:00 UTC 2007
Am Sonntag 30 Dezember 2007 11:38 schrieb Andreas Metzler:
> Thomas Koch <thomas at koch.ro> wrote:
> > I'd like to use some filters in ~/.forward to store emails in separate
> > folders for each mailing list or to: address. As I'm using the dovecot
> > LDA[1], I "only" need to set a variable ($folder) in the sieve/exim
> > filter which I can use in the dovecot transport:
> >
> > dovecot_virtual_delivery:
> > driver = pipe
> > command = /usr/local/libexec/dovecot/deliver -m {$folder} -d
> > $local_part@$domain
> >
> > After reading the better part of a heavy exim book and searching for more
> > then an hour, I've still no idea, how to do this. Any leading hand
> > please?
> >
> > [1] http://wiki.dovecot.org/LDA/Exim
>
> Wouldn't it be more straightforward to use dovecot's sieve support?
> cu andreas
I spent the whole day yesterday to learn more about exim and to tweak my
config. Installing spamassassin was easy: apt-get install and uncommenting
some lines in
/etc/exim4/conf.d/40_exim4-config_check_data
Afterwards I made two copies of
/etc/exim4/conf.d/router/600_exim4-config_userforward
naming them 550_something and 551_something.
I made those routers check for the files .forward.spam and .forward.lists in
the users homedirs.
The .forward.lists filter is an adaption of
http://wiki.exim.org/MailFilteringTips
<code>
# Exim filter
# split out the various list forms
# Mailman & other lists using list-id
if "${if def:header_list-id:{true}}" is true then
if $header_list-id: matches "<([a-z0-9-]+)[.@]" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
else
if $header_list-id: matches "^\\s*<?([a-z0-9-]+)[.@]" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
else
pipe "/usr/lib/dovecot/deliver -m list.unknown"
endif
endif
finish
# Listar and mailman like
elif "${if def:header_x-list-id:{true}}" is true then
if $header_x-list-id: matches "<([a-z0-9-]+)\\\\." then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
else
pipe "/usr/lib/dovecot/deliver -m list.unknown"
endif
finish
# Ezmlm
elif "${if def:header_mailing-list:{true}}" is true then
if $header_mailing-list: matches "([a-z0-9-]+)@" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
else
pipe "/usr/lib/dovecot/deliver -m list.unknown"
endif
finish
# York lists service
elif "${if def:header_x-mailing-list:{true}}" is true then
if $header_x-mailing-list: matches "^\\s*([a-z0-9-]+)@?" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
else
pipe "/usr/lib/dovecot/deliver -m list.unknown"
endif
finish
# Smartlist
elif "${if def:header_x-loop:{true}}" is true then
# I don't have any of these to compare against now
pipe "/usr/lib/dovecot/deliver -m list.xloop"
finish
# poorly identified
elif $sender_address contains "owner-" then
if $sender_address matches "owner-([a-z0-9-]+)-outgoing@" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
elif $sender_address matches "owner-([a-z0-9-]+)@" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
elif $header_sender: matches "owner-([a-z0-9-]+)@" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
else
pipe "/usr/lib/dovecot/deliver -m list.unknown"
endif
finish
# other poorly identified
elif $sender_address contains "-request" then
if $sender_address matches "([a-z0-9-]+)-request@" then
pipe "/usr/lib/dovecot/deliver -m list.${lc:$1}"
else
pipe "/usr/lib/dovecot/deliver -m list.unknown"
endif
finish
endif
</code>
After doing this I could make the .forward.spam filter myself:
<code>
# Exim filter
if "${if def:header_X-Spam_score_int:{true}}" is true then
if $header_X-Spam_score_int is above 70 then
pipe "/usr/lib/dovecot/deliver -m spam"
endif
endif
</code>
The next two steps are:
* droping spams when the score is above a certain limit
* putting the .forward.something files in a dir outside of /home so that every
user can use them via symlinking.
Cheers,
Thomas Koch
http://www.koch.ro
More information about the Pkg-exim4-users
mailing list