The Exim FAQ

Contents   Previous   Next

5. FILTERING

Q0501:  My filter isn't working. How can I test it?

A0501:  Use the -bf option (-bF for a system filter) to test the basic operation of your filter. You can request debugging information for filtering only by adding -d-all+filter to the command.

Q0502:  What I really need is the ability to obtain the result of a pipe command so that I can filter externally and redirect internally. Is this possible?

A0502:  The result of a pipe command is not available to a filter, because Exim does not run any actual deliveries while filtering. It just sets up deliveries at this time. They all actually happen later. If you want to run pipes and examine their results, you need to set up a single delivery to a delivery agent such as procmail which provides this kind of facility.

An possible alternative is to use the ${run expansion item to run an external command while filtering. In this case, you can make use of some of the results of the command.

Q0503:  I received a message with a Subject: line that contained a non-printing character (a carriage return). This messed up my filter file. Is there a way to get round it?

A0503:  Instead of $h_subject: use ${escape:$h_subject:}

Q0504:  I want to search for $ in the subject line, but I can't seem to get the syntax.

A0504:  Try one of these:

   if $h_subject: contains \$ then ...
   if $h_subject: contains "\\$" then ...

Q0505:  My problem is that Exim replaces $local_part with an empty string in the system filtering. What's wrong or what did I miss?

A0505:  A message may have many recipients. The system filter is run just once at the start of a delivery attempt. Consequently, it does not make sense to set $local_part. Which recipient should it be set to? However, you can access all the recipients from a system filter via the variable called $recipients.

Q0506:  Using $recipients in a system filter gives me another problem: how can I do a string lookup if $recipients is a list of addresses?

A0506:  Check out the section of the filter specification called Testing a list of addresses. If that doesn't help, you may have to resort to calling an embedded Perl interpreter - but that is expensive.

Q0507:  What are the main differences between using an Exim filter and using procmail?

A0507:  Exim filters and procmail provide different facilities. Exim filters run at routing time, before any deliveries are done. A filter is like a ``.forward file with conditions''. One of the benefits is de-duplication. Another is that if you forward, you are forwarding the original message.

However, this does mean that pipes etc. are not run at filtering time, nor can you change the headers, because the message may have other recipients and Exim keeps only a single set of headers.

procmail runs at delivery time. This is for one recipient only, and so it can change headers, run pipes and check the results, etc. However, if it wants to forward, it has to create a new message containing a copy of the original message.

It's your choice as to which of these you use. You can of course use both.



Contents   Previous   Next