Re: [exim] Add a filter to Exim

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Michael Sprague
Datum:  
To: exim-users
Betreff: Re: [exim] Add a filter to Exim
On Mon, Jun 18, 2007 at 07:43:03PM +0200, Sébastien CARRE wrote:
> Hello,
>
> Actually I use Exim 4 with a Linux Debian 4.0, everything works
> perfectly since a few months.
>
> But I had a question about Exim and filters...
>
> I just want to make a very easy filter, that make a copy of each mail
> that exim receives...
>
> For the moment, I use a .forward file in any user local dir, it works...
> but it's not as good as a filter created in Exim! And the
> outgoing mails (outside the domain) are not
>
>
> Thanks for your reply.
>
>
> Sebastien


Hi Sebastien,

Sounds like you want to use a system filter. This page of the docs has
the whole thing:

http://www.exim.org/exim-html-4.66/doc/html/spec_html/ch43.html

As a sample, here is something I did one a server in the past. First
you need to specify the system filter in the conf file;

system_filter = /etc/exim4/system_filter
system_filter_user = Debian-exim
system_filter_group = Debian-exim
system_filter_file_transport = address_file
system_filter_directory_transport = address_directory

Then you need to build your filter. In sample above, that would be the
contents of /etc/exim4/system_filter:

# Set the logfile.
logfile /var/log/exim4/filter.log 640

# If the incoming message is an error message, drop out of the filter
# and let the bounce proceed as normal. This is a safety net in case something
# is really broken.
if error_message then finish endif

# We only want to do things once so we check for first_delivery.
if not first_delivery then finish endif

if $tod_log matches "\\N^(\\d{4})-(\\d\\d)-(\\d\\d)\\d\\d:\\d\\d:\\d\\d$\\N"
then
    logwrite "$tod_log $message_id $sender_address $recipients $h_subject:"
    unseen save /var/exim/archive/today/
endif


finish

Of course this is just a sample so you get the idea. The above would
store the messages in maildir format in /var/exim/archive/today.

Hope this helps,
mikeS

-- 
Michael F. Sprague     | mfs@???
http://www.saneinc.net | System and Network Engineering (SaNE), Inc
Providers of the SpamOnion anti-spam service