How can I find my local mail spool?
Mail spools are typically under here:
/var/spool/mail/$USER
Where $USER
is your username. For example on my Fedora Linux system:
$ ls -l /var/spool/mail/
total 1908
-rw-------. 1 root root 1943163 Jul 13 12:00 root
-rw-rw----. 1 rpc mail 0 Dec 18 2010 rpc
-rw-rw----. 1 saml mail 689 Jul 12 19:38 saml
Mail spools however are not necessarily local. If you do not have this file then your mail is being maintained on another server. You can either interact with this server using protocols such as IMAP or POP3.
It is on this system where your mail spool is being maintained.
In some environments the mail spool can be shared out as part of a user's home directory, often times in a directory called mail
($HOME/mail)
. Other times it can be shared out as its own share under something like /mail/users/$USER
.
It really depends on how the sysadmins within a given environment choose to do so.
Unless your machine is misconfigured, the command mail
(or other mail programs such as mutt
) will access your local mailbox. Usually the local mailbox is either /var/spool/mail/$USER
or /var/mail/$USER
. If the mailbox is in a non-standard location, the system administrator may have configured the system to set the MAIL
environment variable to the location of your mailbox.
If you've never received mail on that machine, then the file won't exist. Send yourself a mail, and the file will be created.
If any mail is ever delivered on this machine, then a mail transfer agent is running. You wouldn't ever interact directly with the MTA: it's something that the administrator set up.
The existence of the files /var/spool/mail/nobody
and /var/spool/mail/www-data
shows that there is (or was) an MTA running and delivering mail locally. They probably contain reports from cron jobs.
You will only be able to receive mail from other machines if that machine is configured to receive mail. In a multiple-computer environment, it is common to configure a single machine to receive all mail. This is indicated through DNS. If there is an MX record for a host, it indicates which host is to receive the mail intended for that host. You can see the MX record with host -t MX $HOSTNAME
or dig MX $HOSTNAME
.
Even if you are receiving mail locally, it's possible that it is redirected to another machine. Check if you have a file called .forward
in your home directory: it contains an email address to redirect your mail to, or some other directive telling the MTA what to do when you receive mail. You may also have a .procmailrc
file if the MTA is configured to use procmail to deliver the mail, which is fairly common.
You should find it in either /var/spool/mail/
(the traditional location) or /var/mail
(new recommended location). Note that one may be a symbolic link to the other, so it's best to go to the one that is an actual directory (and not just a link). Here you should find a file called the same as your username, that is your mailbox. It should be owned by you, so you should easily be able to make a copy of it.