Configuring procmail with The Dotfile Generator
The most common condition to set up is to match one of the header fields with a given regular expression, or to match the body of the letter with a given regular expression. A typical header is shown in Listing 1.
The very first line of the header is special and has been written by the program (often sendmail) sending the letter. This header field is always the same for a given mailing list, so to sort mail from a mailing list, it is a good idea to view the letter with an ordinary file reader (a mail reader will seldom show this line). Copy this information to the pattern field (Figure 4, label (6) ). As the element to match, you have to select "Sendmail from" in entry (5).
Three special macros exist in procmail. These may be used when matching header fields:
TO: This macro matches every destination specification.
FROM_DAEMON: This macro should match when the letter comes from a daemon (which includes mailing lists). It is useful to avoid creating a mail loop with some mailing lists.
FROM_MAILER: Another regular expression, which should produce a match when the letter comes from the mail daemon.
To see what these macros stand for, please refer to the procmailrc man page.
There are many header fields to choose between in the pull down menu (5), but if the one you wish to select isn't located there, you may type it yourself.
The check box (4) may be used to negate the condition, i.e., if the pattern does not match, the condition is fulfilled.
So far, I have mentioned that you can type a regular expression in box (6). In most cases, it may not be necessary to know anything about regular expressions since the procmail module will take care of most of it for you. One thing may be worth knowing, and that is that you may match “anything” with ".*". This means that abc.*def will match anything which starts with abc and ends with def, e.g., abcdef or abcXXXXdef. To read a more detailed description of the set of regular expressions used by procmail, press the button labeled Description.
One common pitfall is to forget to match everything at the start of the line. If you wish to set up a regular expression for the From: field above, it is not enough to give the pattern: email@example.com, since this is not at the start of the line. Instead, to tell procmail that every mail message which includes the text firstname.lastname@example.org is to be handled, insert .* in front of the e-mail address.
A final way to set up a condition is by using an external program to verify some conditions. This is done by pressing button (7) which brings up a window with a FillOut field like the one in Figure 3. This time, however, the entry has been replaced with a text box. In this text box, you can type some commands to read either the header or the body on standard input. These commands can refer to any header fields from the letter. The lines (separated by a newline) are joined together with a separating semicolon, making each line a separate command.
Procmail will consider the condition fulfilled only if the exit code from the program is 0. This behavior can be changed with the check button (4) in Figure 4.
The actions that this module can handle are split into six parts. These are described in detail below. To activate an action, you first have to select the check box that is located next to it, making it clear which actions are enabled for a given recipe.
To set up a filter, press the button labeled Predesigned Filters in the window. This filter can change the header fields, add new header fields and/or remove existing header fields.
On this page you will find one custom-made filter: Remove signatures. With this filter, you may specify a signature for each e-mail address. If the text you specify is found (exactly), it will be removed from the letter. My intention is to add more custom-made filters as users send me their ideas and filters.
If you wish to create your own filter, you must go to the page Handmade Filters. On this page, you may send the header and/or the body of a letter through a command.
As an example, you may remove the header with the command
cat ->> /dev/null
or add a message to the body of a message with the command:
echo This letter has been resent to you, by my\ procmail filter!; cat -If only the filter action is selected, the filter will change the letter permanently, i.e. the changes will affect the subsequent recipes (even on the delivered letter, if no recipes match). This may be useful if you use a mail reader that does not support MIME, and you have a filter to convert MIME-encoded text to 7-bit ASCII. If, however, one of the other actions is also enabled, the changes affect only this recipe.
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
|Trying to Tame the Tablet||May 08, 2013|
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- Tech Tip: Really Simple HTTP Server with Python
- RSS Feeds
- Find new cell phone and tablet pc
27 min 51 sec ago
1 hour 56 min ago
- Automatically updating Guest Additions
3 hours 5 min ago
- I like your topic on android
3 hours 51 min ago
- Reply to comment | Linux Journal
4 hours 12 min ago
- This is the easiest tutorial
10 hours 27 min ago
- Ahh, the Koolaid.
16 hours 5 min ago
- git-annex assistant
22 hours 5 min ago
- direct cable connection
22 hours 28 min ago
- Agreed on AirDroid. With my
22 hours 38 min ago