Classic Linux
This page provides hints for using the Procmail mail-filtering program in our new Classic Linux environment, beginning with the server oxygen.rahul.net. Some of the hints below will also apply to the older Classic linux servers, as documented below.
Most of this information will make sense to you only if you have some familiarity with the
use of procmail and .procmailrc files.
Otherwise simply make sure you
do not have any .procmailrc file in your home directory and then
you can safely ignore everything on this page.
Please see the page Mailbox Changes for definitions of the terms old inbox and new inbox, and for reserved directory names.
Mail delivery on this system is done by procmail and, in the absence of any
contrary instructions in your .procmailrc file, procmail will
deliver mail into your new inbox, which resides in your Maildir directory.
To cause procmail to
deliver into any other folder, the conventions below may be used. The
examples below show unconditional delivery. To add conditions, simply
include the conditions before the delivery line as you always do.
To deliver into an old-style mailbox called mbox that resides in your home directory:
:0: mbox
(The above is not recommended, as it might not be easily visible via IMAP.)
To deliver into an old-style mailbox called mbox that resides inside the directory Mail:
:0: Mail/mbox
To deliver into a Maildir format directory called maildirname that resides in your home directory:
:0 maildirname/
To deliver into your new inbox:
:0 Maildir/
To deliver into a folder called ”spam” which will become visible via IMAP, carefully note the dot
in the name below. Even though the pathname uses a dot, the name of this folder when accessed via IMAP
will be just “spam”. In general, for any value of xxx, a directory ”.xxx” within your Maildir directory
appears in IMAP as a folder called “xxx”:
:0 Maildir/.spam/
To deliver into a folder called “example.com” (i.e., one whose name contains a dot):
:0 Maildir/.example.com/
(Note: In most cases this will appear to your mail client as ”example/com”, i.e.,
as a folder ”com” inside a folder ”example”. Try it and see.)
To deliver into your MH inbox:
:0 MH/inbox/.
Note. No lockfile is used when delivering into a Maildir directory or
an MH directory. Hence we omit a trailing colon and we specify ”:0”
and not ”:0:”. If you include the trailing colon, thereby causing
a lockfile to be used, delivery may fail.
Note. The trailing dot is the only difference between delivering into a Maildir directory and an MH directory.
Note. The syntaxes shown are valid on all servers, old and new. So you can begin
using the example recipes shown above now in your .procmailrc file.
The hints below tell you how to have your mail forwarded to oxygen.rahul.net so you can take advantage of the newer Maildir mailbox format.
You can conditionally forward your mail so it always goes to
oxygen.rahul.net. Near the beginning of your .procmailrc file,
use lines as shown below. In place of USER use your own login name.
The use of the ”:0c” string causes a copy to be forwarded, so your
mail will be duplicated on oxygen.rahul.net. This is for testing.
Once you are ready to read your mail only on oxygen.rahul.net,
replace ”:0c” with ”:0”.
################################################################# ##### Revised 2009-09-26. ##### If not on oxygen.rahul.net, forward to oxygen.rahul.net. ##### ##### Note: Send to "USER@only-oxygen.rahul.net", not to ##### "USER@oxygen.rahul.net", as other machines may ##### accept mail destined for oxygen.rahul.net. ##### ##### Note: 0c means forward only a copy. ################################################################# :0c * ? test `hostname` != oxygen.rahul.net !USER@only-oxygen.rahul.net ################################################################# ################################################################# ##### if on oxygen.rahul.net, deliver into our Maildir inbox ################################################################# :0 * ? test `hostname` = oxygen.rahul.net Maildir/ #################################################################
When you ask procmail to deliver into a directory used as a Maildir-format mailbox, procmail requires that that directory either not exist, or be empty, or contain only files and directories appropriate for a Maildir mailbox. If procmail sees extraneous files that don't belong there, it may refuse to deliver into that mailbox.
If and only if you have defined a LOGFILE in your .procmailrc file,
procmail will append an error message into the specified log file of the
form: “Unable to treat as directory”. If you have no LOGFILE directive
in your .procmailrc file, then no error message will appear, so you
will not know that mail delivery into that directory failed.
Procmail will, however, continue executing your .procmailrc file and
will attempt delivery based on subsequent recipes.
Your safest strategy is to not create or edit any Maildir-format mailbox yourself. Let procmail create it as needed and deliver mail into it.
One common reason why this error may occur is if you have a recipe that
treats a mailbox directory (e.g., a directory called travel) as an
MH folder, by specifying it as ”travel/.” (notice the trailing dot).
Later on, you change your
mind, and make it into a maildir mailbox, and you edit the procmail
recipe to specify its name as ”travel/” (notice no trailing dot). If procmail has already
delivered any messages into that directory, it now looks like an MH folder,
and it contains files with names of the form msg.* which are the
messages in MH format. Procmail will now refuse to treat it as a
Maildir format mailbox. To recover from this, delete all msg.* files
from that directory. Or, better still, rename the directory to something
else, and let procmail re-create it as a maildir mailbox.
Due to the mail system changes in progress, we recommend that you make your .procmailrc
file as fail-safe as possible, so that no useful mail is ever lost. Near the end of your
.procmailrc file, you may insert lines similar to the following:
# Deliver into Maildir. :0 Maildir/ # Only if Maildir delivery above fails, try an old-style mailbox. :0: Mail/incoming # If that fails too, try putting it into /bigtemp. # Create directory if needed. :0: * ? mkdir -p /bigtemp/joeuser /bigtemp/joeuser/emergencymailbox # Only if the above also fails, mail the message to my offsite account. :0 !USER@freemailservicesomewhere.org
Do not just copy-and-paste these lines into your .procmailrc file, but
insert lines that actually do what you want.
The above example code will be executed by procmail only if the message hasn't yet
been delivered. It will attempt to deliver it into your Maildir inbox
or, failing that, into a mbox-style mailbox in your home directory or
else in your /bigtemp directory. If that also fails, it will
mail the message to your offsite email address. Many free email
providers on the Internet offer large mailboxes. An email address
at one of these providers can serve as a last-resort offsite location, so
you never lose mail even if things go wrong here. Don't forward mail
in both directions (i.e., here to there and also there to here) else
you will get a mail loop and the message will be lost.
Also, at any point, if your procmail script decides that it cannot complete delivery, you can make it exit with decimal value 75. This will tell the mail system to keep mail queued and retry deliver later. When the queue is run again, your procmail script will once again run from the beginning on the same mail message.