Configuring procmail with The Dotfile Generator
In this article, I'll describe how to configure procmail using The Dotfile Generator (TDG for short). This will include:
How to sort mail coming from different mailing lists
How to setup an auto reply filter when you are on vacation
How to change some part of a letter, e.g., remove the signature
How to avoid lost mail
If you haven't downloaded the program, now is the time to do it. The home page of TDG at http://www.imada.uo.dk/~blackie/dotfile/ provides a list of mirror sites. An earlier article, giving details about the program and the installation of TDG, appeared in Linux Journal October 1997, Issue 42.
To start TDG with the procmail module, type dotfile<\!s>procmail, and the window shown in Figure 1 will appear. As you can see, the module is split into three pages. The first two are very simple, so let's start with the page called General Setup. This page is shown in Figure 2.
On this page there are four items to configure:
The directory to use as prefix for all file operations. This is simply for convenience, since all file operations may be given using the file's full prefix.
Your e-mail address, which is used in preventing loop-backs.
Configuration of log files. These files are very useful when you wish to investigate mail destinations. If you turn on abstract logging, you may find the program mailstat very useful. (See the log file below.)
The search path, in which procmail may find the programs it needs. Note this is only the programs, which you specify in filters etc.
Since procmail handles your incoming mail, security is very important to this module. You can back up your incoming mail in three different ways. To do this, go to the page called Backup shown in Figure 3.
The first backup category is “back up all incoming mail”. The code needed by the procmailrc file to do this is typed in the very first field. This is done to avoid any errors in the generated procmail file that might cause any of your mail to be thrown away. This sort of backup is only a good idea when you first start to use the generated procmail file. The main drawback is that all incoming mail is saved in one file, so this file can become very big, very quickly.
The second method is to backup all incoming mail that is delivered by procmail. This method makes it easy to verify that mail is sorted into the right places.
The third method is to back up all mail that makes it to your incoming mailbox. This mail is often personal mail; that is, it did not come from a mailing list, and it is not junk mail.
In the first method, the full file name must be specified. This is because this method has to be 100% foolproof. In the other two methods, you may build the file names from the current date and time. This makes it possible to save this sort of mail to folders for the current year/month/week, e.g., a folder called backup-delivered-1997-July. As an additional feature, you may compress the files as gzipped files.
The backup of delivered mail can be specified for each individual recipe or for all recipes at once. (See Figure 4, check box 9.) The FillOut elements, which configure the saved file are discussed in the previous article.
In procmail a central concept is a recipe, which is a set of conditions and a set of actions. All of the actions are executed if all of the conditions are fulfilled. A few examples of conditions appear below:
The letter comes from email@example.com.
The subject is subscribe.
The size of the letter is greater than 1MB.
The letter contains text.
A list of actions includes:
Reply to the sender that you are on holiday.
Forward the letter to another person.
Save the letter to a file.
Change some part of the letter (e.g., add a new header field or add some text to it).
A procmail configuration is a sequence of recipes. When a letter arrives, each recipe is checked to see if all of its conditions are fulfilled. If they are, the actions of the recipe are executed.
Procmail will finish testing recipes when one is matched, unless a flag is set to tell it that this recipe should not stop delivery (see Figure 4 check box 8). This means that the order of the recipes is important, since only the first recipe to match will process the letter.
If none of the recipes are fulfilled, or if the ones which are fulfilled have check box 8 in Figure 4 set, the letter is delivered to the incoming mailbox as if the procmail filter did not exist.
You configure the recipes on the page called “Recipes”. This page can be seen in Figure 4.
What you see here is an ExtEntry. An ExtEntry is a widget, which repeats its elements as many times as necessary (just like a list box repeats the labels). Everything on this page is one single recipe. To see a new recipe, you have to scroll the outer scroll bar (1). To add a new recipe, you have to press the Add button beneath the scroll bar.
As described above, a recipe is a set of conditions. This set is also represented with an ExtEntry (2). To scroll to another condition in a recipe you must use the scroll bar (2), and to add a new condition you must use the button below scroll bar (2).
Each recipe can be given a unique name to make it easier to find a given recipe. This name is also written to the file with mail delivered by recipes (method 2 above), so that you can see which recipe matched the actual letter. To give a recipe a name, use entry (3). A button labeled Idx is located at the right side of the entry. This is a quick index to the outer ExtEntry (i.e., the recipes). If you press this button, a list box drops down from which you can select one of the recipes by name.
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|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|
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- RSS Feeds
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- Readers' Choice Awards
- Tech Tip: Really Simple HTTP Server with Python
- Reply to comment | Linux Journal
26 min 10 sec ago
- All the articles you talked
2 hours 49 min ago
- All the articles you talked
2 hours 52 min ago
- All the articles you talked
2 hours 54 min ago
7 hours 18 min ago
- Keeping track of IP address
9 hours 9 min ago
- Roll your own dynamic dns
14 hours 23 min ago
- Please correct the URL for Salt Stack's web site
17 hours 34 min ago
- Android is Linux -- why no better inter-operation
19 hours 50 min ago
- Connecting Android device to desktop Linux via USB
20 hours 18 min ago