COURIERPERLFILTER(8) | Double Precision, Inc. | COURIERPERLFILTER(8) |
NAME¶
courierperlfilter - Sample Perl-based mail filterSYNOPSIS¶
filterctl
[[start] | [stop]] [perlfilter]
DESCRIPTION¶
This is an example global mail filter that uses an embedded Perl script. "Embedded" means that the Perl interpreter is loaded once, and the same Perl code is repeatedly called to accept or reject incoming messages, one by one. Perl filtering is relatively time consuming (compared to filtering in C or C++), and excessive delays in mail filters result in incoming mail being deferred (rejected with a temporary error code). Therefore the perlfilter wrapper can create multiple perlfilter processes, so that multiple processes are used to filter incoming mail.Setting up a Perl script¶
Most of the ugly details of connecting the Perl script to Courier´s mail filtering engine is taken care of by the sample perlfilter-example.pl script. One big no-no: the script MAY NOT change the current directory. Anything else goes, for the most part. Loading other modules and classes, pretty much anything else you can do with Perl, is allowed. The Perl script, just like any other mail filtering module, receives a pointer to a data file and one or more control files, each time a message is submitted to Courier for delivery. The sample script calls the filterdata() function to process the data file. The data file contains the actual message. The filtercontrol() function is called to process each control file. The control file contains recipient and message metadata. There may be more than one control file for each message. The example script includes an implementation of filterdata() that blocks messages with corrupted headers. The example script doesn´t do anything interesting with filtercontrol().CREDITS¶
A lot of the Perl glue code is based on examples from the perlembed manual page, and other sources.FILES¶
If this file exists and contains the word
"all", perlfilter will create its socket in
/var/lib/courier/allfilters, otherwise the socket will be created in
/var/lib/courier/filters, see courierfilter(8)[1] for more
information.
/etc/courier/filters/perlfilter-numprocs
This file contains a number that sets how many
perlfilter processes are created. The default is 5 processes.
There´s always an extra perlfilter process that´s used to
clean up crashed child processes.
/etc/courier/filters/perlfilter
This file MUST exist and it must contain a
single line of text with the filename of the Perl script to load.
/usr/lib/courier/perlfilter-example.pl
This is a sample Perl script of the kind that
/etc/courier/filters/perlfilter points to. Use it as an example of writing
your own Perl filters.
Please exercise good judgment in writing Perl-based filters. They should be
reasonably fast, and do not allocate megabytes of memory. They should not be
very promiscuous in creating global Perl variables, and should clean up after
themselves. The current Perl wrapper does not destroy the Perl symbol table
after each call to the filter script. However, do not take that for granted.
This may change in the future.
SEE ALSO¶
AUTHOR¶
Sam VarshavchikAuthor
NOTES¶
[set
$man.base.url.for.relative.links]/courierfilter.html
04/04/2011 | Courier Mail Server |