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.
echo $MAIL
echo $MAIL
, it returns/var/mail/myusername
, wheremyusername
is my username. But when I navigate to/var/mail/
, the filemyusername
does not exist there.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.(echo Subject: test; echo) | /usr/sbin/sendmail -i YOUR_LOGIN
. Sendmail stub is provided by other MTA servers too (e.g. postfix, exim).