224
Chapter 15. Email
$
Refers to a variable set earlier in the
rc
file. This is usually used to set a common mailbox that
will be referred to by various recipes.
|
The pipe character tells Procmail to start a specific program to deal with this message.
{
and
}
Constructs a nesting block, used to contain additional recipes to apply to matching
messages.
If no special character is used at the beginning of the action line, then Procmail assumes that the action
line is specifying a mailbox where the message should be written.
15.5.2.5. Recipe Examples
Procmail is an extremely flexible program, allowing you to match messages with very specific condi
tions and then perform detailed actions on them. As a result of this flexibility, however, composing a
Procmail recipe from scratch to achieve a certain goal can be difficult for new users.
The best way to develop the skills to build Procmail recipe conditions stems from a strong understand
ing of regular expressions combined with looking at many examples built by others. The following
very basic examples exist to serve as a demonstration of the structure of Procmail recipes and can
provide the foundation for more intricate constructions.
The most basic recipes does not even contain conditions, as is illustrated in the following example.
:0:
new mail.spool
The first line starts the recipe by specifying that a local lockfile is to be created but does not specify
a name, leaving Procmail to use the destination filename and the
LOCKEXT
to name it. No condition
is specified, so every message will match this recipe and, therefore, will be placed in the single spool
file called
new mail.spool
, located within the directory specified by the
MAILDIR
environment
variable. An MUA can then view the messages in this file.
This basic recipe could go at the end of all
rc
files to direct messages to a default location. A more
complicated example might grab messages from a particular email address and throw them away, as
can be seen in this example.
:0
* ^From: spammer@domain.com
/dev/null
With this example, any messages sent by
spammer@domain.com
are immediately moved to
/dev/null
, deleting them.
Caution
Be very careful that a rule is working correctly before moving messages matching it to /dev/null,
which is a permanent deletion. If your recipe conditions inadvertently catch unintended messages,
you will not even know you are missing those messages unless the sender tells you.
A better solution is to point the recipe's action to a special mailbox that you can check from time to
time in order to look for false positives, or messages that inadvertently matched the conditions. Once
you are satisfied that no messages are accidentally being matched, you can delete the mailbox and
direct the action to send the messages to /dev/null.
Procmail is primarily used as a filter for email, automatically placing it in the right place so that you
do not have to sort it manually. The following recipe in grabs email sent from a particular mailing list
and puts in the correct folder for you.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved