procmail and sieve Flashcards
Controlling the message delivery with procmail or sieve
What command do you need to add to your m4 macro file to have sendmail use procmail MDA?
MAILER(`procmail’)dnl
What command do you need to add to main.cf to have postfix use procmail MDA?
mailbox_command = /usr/bin/procmail -m /etc/procmailrc
Where is the common recipes stored for procmail (for use by all users)
/etc/procmailrc
Where is the user procmail recipes defined?
$HOME/.procmailrc
Procmail recipes are made up of 3 components what are they?
A header line, Condition Line(s) and an action line
In a procmail recipe, what does this header do?
It specifies that procmail should use default flags (which are Hhb) and to utilize a default lock file.
Flags:
H = egrep message header
h = feed the header of the message to the destination
b = feed the body of the message to the destination
Why are lock files needed for procmail recipes?
When using mbox style mailboxes all mail is stored in one file, so it is necessary to lock the file while in use. If you are using Maildir style mailboxes the lock file is not required.
What does this procmail recipe do?
:0 c
messages
It copies all messages into a file called “messages”
What does this procmail recipe do?
\:0 * ^From.*guitar-list { :0 c ! ted@smallorg.org :0 guitars }
For messages from guitar-list, it copies the message to both tad@smallorg.org and into the file “guitars”
note: don’t confuse the ! on the action line (which forwards a message) with the ! on a condition line (which inverts a condition
What does this procmail recipe do?
:0
* ^Subject.*work
/dev/null
It redirects all mail with work in the subject line to /dev/null.
These are the procmail action line characters, what do they do? ! | { } text
! forwards message to a specified address
| starts a specified program
{ starts a block of recipes (if condition was matched)
} ends a block of recipes
text forwards message into the mailbox named text
These are the procmail special condition characters, what do they do? ! $ ? < > variable ?? \
! inverts the condition
$ evaluates the condition according to shell substitution rules inside double quotes
? uses the exit code of the specified program
< checks if the message length is less than number specified
> checks if the message length is greater than the number specified
matches the remainder of the condition against the environment variable specified ??
\ quotes any of the special characters to use as normal characters
The Sieve programming language is made up of what 3 types of commands?
Action commands
Control commands
Test commnds
What are the 4 action commands available in sieve?
keep - save the message
fileinto - save a copy into specified location
redirect - forward the message
discard - silently ignore the message
a five command is optionally available:
reject - refuse a message with a reason
What are the 3 control commands available in sieve?
if - perform conditional check
require - add external extension(s) to script
stop - end processing