[imapfilter-devel] Request for external "mask"

Per Westerlund perw at gbg.dimension.se
Fri Nov 14 17:17:24 EET 2003


Problem:

Sometimes the decision whether to move a message to the "log" folder or 
to keep it and mark it as "important" cannot be made using only fixed 
strings in your matching expressions. It is not enough even to be able 
to use regular expressions, sometimes a more thorough parsing of the 
content of a message is required.

Proposal:

For those occasions when you need better decision support tools, let us 
be able to use an external program. Why not like this:

[mask] [or|and] [not] external <path-to-external-program> [header]

'mask', 'or', 'and' and 'not' work as for all other filter entries. 
IMAPFilter runs this filter entry by starting <path-to-external-program> 
with no arguments, and connecting a pipe to it. Through this pipe is 
then fed the body of the message (normally) or, if the optional argument 
'header' is supplied, the header and the body. The external program 
signals success (condition fulfilled) by exit code 0, everything else 
signals failure (condition not met).

Implementation note:

It is important that the filter entries use "short circuiting" so that 
an external program placed last in the list is not queried if the total 
condition has alerady failed.

A timeout for the external program should be implemented.

Watch out for SIGPIPE or similar problems it the external program exits 
prematurely.

/Per Westerlund




More information about the Imapfilter-devel mailing list