The Procmail Setup Generator

revision date: 02-Oct-2001
First issue.
revision date: 26-Nov-2001
Added default locks when writing to mail files. Nobody's complained, and I didn't notice anything in testing, but it's the right thing to do.
revision by: Fred Morris
version: 1.3 live
Written by Fred Morris. Copyright (c) 2001 by Fred Morris, DBA Fred Morris Consulting. Fred Morris hereby grants you (this means you) a perpetual and royalty-free license to derive from, modify and redistribute it provided that you adhere to the following two conditions: 1) you must reproduce this copyright statement and additionally make visible alterations sufficient to prevent confusion with the original work, and 2) you hold Fred Morris and Fred Morris Consulting harmless for any damages incurred as a result of your use or attempt to use this page.


This is a more couth version of the Artless Procmail Generator. Basically I changed the wording of the prompts so that it would be more acceptable in a corporate setting, and added some explanatory text on redirecting the script output. The operation of the underlying script is unchanged.

Obligatory warning and hold harmless

Obviously this is a tricky bit of coding, a script generating a script which generates a script. But what it does should be straightforward, if you understand what it does. Aye, therein lies the problem: how many people using this are going to understand any of it?

While I have received absolutely no reports as of this writing (and it's been up for three months) regarding improper operation or other mayhem, I have a number of concerns about it:

If I didn't tell you the above, I'd be remiss.

If you're not swayed by any of this and you accept all responsibility as well as liability for what happens, follow these simple steps to set up procmail:

1. Fill out the following form:

My account (login) name is:

Your login name is needed to identify your procmail thread, and is also used for testing BCCs.

My hosting domain is:

Your hosting domain will be concatenated with your login name to create the From line for forwards. For example, if your account name is warfin and your hosting domain is yoyodyne.com, then warfin@yoyodyne.com will be used as the From line for your forwards.

My mail folder directory is named:

If what's entered here is a folder name, it will be rooted from your login directory, e.g. "./mail" which should work right most of the time. If it starts with a leading slash, it will be rooted from root as an absolute path.

Procmail is located here:

Assert csh as shell

Shouldn't hurt to do this. Leave it turned on unless you have problems.

Enable Logging

Debugging information will be written to a file named procmail.log. Also a good idea, as long as you remember to delete the procmail.log file once in a while!

I want to save mail from someone into a mail folder

Mail from this person will be saved, unless it also meets the criteria for forwarding.

Their username is:

Enter as much or as little of their username as you wish. You can enter their domain instead.

Name the folder:

Make it a copy, so I can still pick it up with my POP-based e-mail client
I'll just use pine or some other unix shell mail client
Delete all mail from this person

I want to save stuff with a certain subject to a mail folder

Mail from this person will be saved, unless they already met the criteria for having their mail saved based on who it is from, or meets the criteria for forwarding.

The subject is:

Enter as much or as little of the subject as you wish.

Name the folder:

Make it a copy, so I can still pick it up with my POP-based e-mail client
I'll just use pine or some other unix shell mail client
Delete all mail with this subject

BCC Handling

Mail which is not address to the login name you entered will be handled, unless it already met the criteria for being saved based on who it was from or what the subject was.

Name the folder to store them in:

Just tag 'em with an X-Artless header, I'll pick them up with my POP-based e-mail client
Drop them in the folder, and just leave the headers for the POP client
Drop them in the folder, I'll just use pine or some other unix shell mail client
Delete them
Delete them, regardless of who they are from or what the subject is

Treat mail from this address the same way:

I want to forward some stuff to somebody

Mail will be forwarded, unless it meets the criteria for being treated as a BCC.

Their e-mail address is:

Enter their full e-mail address.

The subject is:

and
or

It comes from this address:

The name of my folder is:

Make a copy. Just tag 'em with an X-Artless header, I'll deal with them after I pick them up with my POP-based e-mail client.
Make a copy. Drop them in the folder, and just leave the headers for POP client
Make a copy. Drop them in the folder, I'll use pine or some other unix shell mail client
Don't save me a copy

Filter out IMG tags with perl

If your terminal emulator wraps what you paste in, this one may not work.

Perl is located here:

2. Click the button.

3. Log in to your ISP's shell box with telnet.

No shellee, no workee! No csh shell no workee either. I strongly suggest that you copy and paste the following in first, and see if it works:

csh
echo 'it works!'
exit

4. Copy all of the text from the following box:

Creating multiple scripts for comparison purposes

A lot of people learn by example; that was one of the objectives in developing this tool. The script above saves a copy of your .procmailrc and .forward files, and then overwrites them. You may want to utilize this tool by generating multiple procmailrc files after choosing different settings, and then comparing them. To do that, edit the following lines at the beginning of the script above (you should be able to do it right in the textbox).

Change this:

set ofnm = 'procmailrc.old'
set nfnm = '.procmailrc'
set ofwd = 'forward.old'
set nfwd = '.forward'

To something like this:

set ofnm = 'test1.old'
set nfnm = 'test1'
set ofwd = 'forward1.old'
set nfwd = 'forward1'

The .forward file doesn't actually change, it will be the same no matter how you configure the script; however, renaming it prevents your existing .forward from being overwritten.

By the way, your .forward and .procmailrc are "invisible" files

Unix uses a convention that unless you specify a special flag, any file beginning with a period is invisible. For instance,

ls

will not show you those files! To see them, use the -a flag:

ls -a

5. Paste it into your shell session.

Select all of the text in the textbox, and paste it into your shell session.

6. Test.

Spoof mail to yourself, or have your friends do it.

If you used perl filtering for IMG tags, it would be prudent to examine the generated .procmailrc file to make sure that the perl rule didn't get wrapped or otherwise munged.

If it doesn't work, log in to a shell session again and cut & paste the following code to disable filtering:

cd
rm .forward

Epilogue

For more information on procmail, see my procmail guide or visit procmail.org.

This page will remain posted at my site as a reference copy; don't expect too many modifications.


Fred Morris Consulting, Licensed in Seattle, WA, USA. since 1984

Document/Collaboration/Content Management Tools and Solutions

Better, Cheaper, Highly Adaptable, Less Hassles

Custom and Extraordinary Needs Data Processing Services

What else is on this web site?

An Internet Plumber... not a web cowboy

telephone: 206.297.6344
e-mail: x0xm3047x0xatx0xinwa.net