Admittedly, the documentation on safecat is not all that provocative. On the other hand, safecat is a very simple program--how much is there to say? Not much, if you have plenty of imagination! For the rest, here are some handy-dandy uses of safecat.
Note that in the current version of safecat, you can use either of the following commands interchangeably:
maildir MAILDIR safecat MAILDIR/tmp MAILDIR/new
We have preserved the original semantics of safecat for applications which don't involve qmail maildirs, where a common temp directory is shared by many spool directories. When the following one-liners involve "real" maildirs, we will use the less redundant syntax.
Helping Manage Your Email
If you are a qmail user, you already know something about Dan Bernstein's super-reliable maildir format. If you're a mutt user, you know that maildirs make great mail folders, too. Here are some quick tricks to make life easier for you:
Convert a UNIX mbox to a Maildir
Forget fancy Perl scripts, which don't conform to the maildir algorithm anyway! If you have procmail, you can use its cute little 'formail' program and convert an mbox to a maildir in one line:
formail -I'From ' -s maildir MAILDIR < mbox
Note: this tip assumes the maildir already exists. You can also use it to append messages from multiple mbox files to a single maildir.
Make procmail Deliver to a Maildir
There is a patched procmail, which will deliver to a maildir. What on earth for? Just make a recipe like the following, using the standard-issue procmail:
:0 |maildir MAILDIR
Make fetchmail Deliver to a Maildir
Usually, fetchmail connects to your local SMTP port to deliver email. However, it violates the RFCs in several ways: it mucks around with email envelopes; it doesn't use fully qualified domain names when talking SMTP; under certain conditions it can drop messages on the floor. If you put the following in your .fetchmailrc, then fetchmail's bugs will be less likely to affect you (and you'll save system resources a little, and speed up mail handling, too).
poll SERVER, user USER, password PASSWORD, no rewrite,
mda "/usr/bin/env - /usr/local/bin/maildir ~/Maildir"
Here is the equivalent one-liner:
fetchmail -n -l USER -m "/usr/local/bin/maildir ~/Maildir" SERVER
Make .qmail Files More Flexible
The .qmail-ext files give a lovely, flexible way of handling incoming email in a variety of ways. Suppose, though, that you have a family of related addresses, all delivering to different maildirs. For example, you might subscribe to mailing lists as username-lists-lname@host, and want list mail delivered to a maildir named Mail/lname. You could make a separate .qmail-listname file for each list, or you could put the following line in .qmail-lists-default:
|maildir ./Mail/"$EXT2"
Make sendmail do Maildir Deliveries
Jealous of all your friends who use qmail? Is your home directory mounted with NFS? Well, you can take advantage of the reliability of maildir as well! Just put the following in your .forward file:
|maildir MAILDIR || exit 75 #USERNAME
