Procmail
Procmail | |
---|---|
Basic data
|
|
developer | Procmail Foundation |
Publishing year | 7th December 1990 |
Current version | 3.22 (September 10, 2001) |
operating system | Linux , Unix |
programming language | C. |
category | Mail filter |
License | GPL and AL |
German speaking | No |
www.procmail.org |
Procmail is a Mail Delivery Agent (MDA) that is used to filter email messages on the server .
Usually Procmail is called by a Mail Transfer Agent (MTA) such as Sendmail or Postfix . Procmail can then pre-sort incoming e-mail messages into folders. E-mails can be filtered based on various properties, such as:
- Return address
- receiver
- Subject line
- Membership in a mailing list
- Content of the email
- Spam (in conjunction with spam detection programs such as SpamAssassin )
Procmail uses regular expressions for this purpose . Procmail also has the ability to call up external programs or to automatically reply to e-mails; popular features such as redirects , autoresponders or vacation schedules can be implemented.
To filter emails into existing mailboxes, Procmail provides the utility formail with.
example
The following example of a Procmail control file (usually .procmailrc ) scans incoming mail with SpamAssassin and then filters it.
SHELL=/bin/bash
MAILDIR=$HOME/mail
DEFAULT=$MAILDIR/inbox
LOCKFILE=$HOME/.lockmail
:0fw
| /usr/bin/spamassassin
:0H
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*
/dev/null
:0H:
* ^X-Spam-Status: Yes
./Spam
# Anything that has not been delivered by now will go to $DEFAULT
# using LOCKFILE=$DEFAULT$LOCKEXT
:0
initiates a filter rule. The added fw
rule of the first ensures that Procmail waits until the program is finished. The addition of H
the following two rules ensures that only the headers of the email are searched. A final colon tells Procmail to use file locking. This is always necessary if it is not ensured that the rule can be executed several times in parallel. For example, if a mail is to be sorted into a certain mbox file, which would result in data loss due to simultaneous access .
To explain: First, the email is by means of a pipe to the program spamassassin
sent and waiting until the program is finished. The now scanned mail runs through the next filter rules. SpamAssassin adds the header X-Spam-Status
to e-mails that have been viewed , which is Yes
(for spam detected) or No
(for messages not detected as spam) depending on the threshold set . SpamAssassin also adds a header consisting of *
characters. The number of characters represents the rounded score (i.e. the probability that the message is spam) of the email. The default score by which a message is rated as spam is 5.
The example filters according to the number of characters. If Procmail finds ten or more *
characters, the email is saved in the null device and thus discarded. If a message is generally recognized as spam, the message is saved in the Spam directory . All other e-mails are delivered in the normal inbox.
literature
- The Procmail Companion, Martin McCarthy , Addison-Wesley, p. 256, November 2001, ISBN 0201737906
- Procmail, Chris Lindsey , p. 325, April 2001, ISBN 1565925408