Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am a graduate student and a relative Linux novice. This question is a sort of spin-off of my earlier question. My institution has a Ubuntu Linux cluster. I am just a user; I do not have sysadmin permissions, and I certainly do not have the expertise to be a sysadmin!

My question is, how do I find my local mail spool? As far as I know, I am not using a mail transfer agent. Answers to my previous question suggested that I look for a file /var/spool/mail/$USER, but unfortunately, I do not see a file corresponding to my user name. In /var/spool/mail/, using ls I only see two files: nobody and www-data, which are both extensionless files.

Do you have any other ideas of where I can look for my mail spool (which is probably local, since I do not have a mail transfer agent configured, as far as I know)?

share|improve this question
1  
try echo $MAIL –  Shutupsquare Jul 13 '13 at 18:00
1  
Have you send an email to yourself? Mailbox files are usually created on "as needed" basis. –  Andrzej A. Filip Jul 13 '13 at 18:37
    
@Shutupsquare This is interesting. When I type echo $MAIL, it returns /var/mail/myusername, where myusername is my username. But when I navigate to /var/mail/, the file myusername does not exist there. –  Andrew Jul 13 '13 at 20:45
    
@AndrzejA.Filip Other than using at to send a local message when a scheduled process generates output, how can I try sending a message to myself? This is all so new to me. –  Andrew Jul 13 '13 at 20:51
    
You may use the following command to send test email to yourself:(echo Subject: test; echo) | /usr/sbin/sendmail -i YOUR_LOGIN. Sendmail stub is provided by other MTA servers too (e.g. postfix, exim). –  Andrzej A. Filip Jul 13 '13 at 21:03
add comment

3 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
    
Unfortunately, /var/spool/mail/ and /var/mail/ each have only two files: nobody and www-data, neither of which are my username. Thanks for your time. –  Andrew Jul 13 '13 at 20:37
    
@Andrew - the lack of your username in these directories just tells you that there hasn't been any mail delivered locally on that particular system. –  slm Jul 13 '13 at 22:55
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.