The purpose of mail spools

email

If I understand correctly, a spool is a temporary storage location. Traditionally, the mail is stored in a "mail spool", a mailbox in the /var/spool/mail directory, where users are expected to pick it up. Therefore, according to this view, once the mail has been read it should be deleted or moved elsewhere — most likely somewhere in the user's home directory.

This way of handling the mail doesn't seem very efficient to me. And where does a program such as procmail fit into this scheme? If you have an MDA that automatically stores your mail into folders in your home directory, then why keep a mail spool at all?

Best Answer

With traditional unix mail clients, /var/spool/mail/$USER is the user's inbox. The emails remain there as long as the user decides not to archive the mail. Some mail clients insist on moving emails to a proprietary file, or offer the option to move emails to a different file after reading. Users can choose which mail client they use and how they configure it.

If you run a mail delivery agent (MDA) such as procmail, you can set it up to deliver some emails to the system inbox, or to deliver all emails to files under your home directory (and you can call one of them your inbox if you want). It's a user choice.

Conceptually, you can think of /var/spool/mail/$USER as being a file in your home directory. It pretty much belongs to you. It's in a different location because that file needs to be available during email delivery. Users aren't allowed to create a broken symbolic link or a named pipe where the system expects a regular file, for example, which avoids potentially nasty errors in the delivery system. There are sites where the home directories are on one or more file servers and the mail spools are on a different server.

Related Question