procmail and sieve Flashcards

Controlling the message delivery with procmail or sieve

1
Q

What command do you need to add to your m4 macro file to have sendmail use procmail MDA?

A

MAILER(`procmail’)dnl

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What command do you need to add to main.cf to have postfix use procmail MDA?

A

mailbox_command = /usr/bin/procmail -m /etc/procmailrc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Where is the common recipes stored for procmail (for use by all users)

A

/etc/procmailrc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where is the user procmail recipes defined?

A

$HOME/.procmailrc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Procmail recipes are made up of 3 components what are they?

A

A header line, Condition Line(s) and an action line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In a procmail recipe, what does this header do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why are lock files needed for procmail recipes?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does this procmail recipe do?

:0 c
messages

A

It copies all messages into a file called “messages”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does this procmail recipe do?

\:0
* ^From.*guitar-list
{
  :0 c
      ! ted@smallorg.org
   :0
      guitars
}
A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does this procmail recipe do?

:0
* ^Subject.*work
/dev/null

A

It redirects all mail with work in the subject line to /dev/null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
These are the procmail action line characters, what do they do?
!
|
{
}
text
A

! 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
These are the procmail special condition characters, what do they do?
!
$
?
<
>
variable ??
\
A

! 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The Sieve programming language is made up of what 3 types of commands?

A

Action commands
Control commands
Test commnds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the 4 action commands available in sieve?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the 3 control commands available in sieve?

A

if - perform conditional check
require - add external extension(s) to script
stop - end processing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

There are many test commands in sieve, name some

A

address - compares the address of a sender or recipient
allof - combines multiple tests - logical AND
anyof - combines multiple tests - logical OR
envelope - evaluate part of SMTP commands e.g. From or Rcpt headers
exists - determines if header exists in a message
false - always evaluates to a logical FALSE
header - determines if SMTP headers are present
not - inverts result of test condition
size - evaluates the size of the email message
true - Always evaluates to a logical TRUE

17
Q

This is a simple sieve script, what does it do?

require [“fileinto”];
fileinto “saved”;

A

this script MOVES all messages into a mailbox named “saved”

18
Q

What does this sieve script do?

require ["fileinto"];
if header :is "Sender" "guitar-list.org"
  {
    fileinto "guitars";
  }
  else
  {
    fileinto "saved";
  }
A

This sieve script checks the header of the message, if the message sender if guitar-list.org the message is moved into the mailbox named “guitars”. Otherwise, it is moved into the mailbox named “saved”

19
Q

What does this sieve script do?

require ["fileinto", "reject"];
if header :contains "subject" "pills"
{
  reject "please stop spamming me"
}
elseif address :matches :domain "from" "badhost.com"
{
  discard;
}
A

This sieve script will reject messages with the word “pills” in the subject line, sending the message back to the sender with the message “please stop spamming me”.

Any messages from the domain badhost.com are silently discarded.