Mail Filtering with procmail
Previously, we’ve considered spam suppression features in both
sendmail
and Postfix. These features
can be very effective at blocking some spam before it ever enters your
site. The procmail
program, written
by Stephen van den Berg, offers a different method for accomplishing
this task. The package’s homepage is http://www.procmail.org.
In fact, procmail
is a very
powerful, general-purpose mail filtering facility. Its capabilities are
not limited to removing spam; procmail
can be used for several different
purposes:
To identify spam messages, which can then be discarded or set aside for later examination.
To scan mail for security problems, such as viruses, macros within mail attachments, and so on, allowing you to discard or quarantine suspicious messages.
To sort incoming mail messages by sender, subject area, or any other scheme that makes sense to you.
To reject mail from specific users or sites or with specific characteristics or content (as defined locally); again, such mail can either be discarded or set aside as appropriate.
In fact, procmail
is the mail
filtering tool of choice for most users on Unix systems.
procmail
can be applied to
incoming mail in two main ways:[36] by using it as the local delivery agent (the program to
which the transport agent hands off local messages for actual delivery),
or by piping incoming mail for individual users to it, usually in
the .forward file, as in
this canonical example:
"|IFS=' ' && exec /usr/bin/procmail ...
Get Essential System Administration, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.