When I open up my terminal it says "you have mail", anyone has any idea of why? I am running OS X, but since it too is based on Unix and relies on files such as bashrc, bash_profile etc. I thought somebody here might know, and I'm not sure it's a platform specific problem!


It sounds like something has sent mail on (and to) the machine using the local mail exchanger. Most likely the email is an automated message from some installed package. Once you log in, type mail on the terminal to read and (presumably) delete the relevant mail. (Inside mail, use ? to find out what the commands are.) Once you've read or deleted any unread mail, you won't see the "You have mail" message again until/unless something else sends mail in the same way. Odds are once you know what's sending you the mail, you can find a configuration option to change where it sends it to.


It is a "platform specific problem" :-)

Mac OS X uses as default shell the BASH like many other Un*x/Linux systems.

Mail from your system is stored in mailbox for your user, often located in /var/mail/$user

Because sometimes your mailbox will contain important messages (a failed cronjob task, etc.) you don't to check it every time by yourself.

The BASH (and many other shells) have a feature called mailcheck, which outputs your message the first time you open your terminal.

$MAILCHECK is an environment variable which contains the seconds when its time to check for new mail. Mail is also checked before displaying the primary prompt. See more in man bash - Bash Variables.

To prevent the checks for new mail, you can simply unset $MAILCHECK. The right place for this is your .bashrc file, which will be read when you open up a shell. Its in your user home directory.

Append to ~/.bashrc:


to disable the message.

Of course it is also possible to simply delete the mails like T.J. Crowder mentioned :-)


Using Raspian (Debian based distro for Raspberry Pi) over SSH, I had to comment out the following line in /etc/pam.d/sshd to get rid of it.

session    optional     pam_mail.so standard noenv # [1]
  • 4
    Could you comment a bit more on how you found this out? It might be of help to people with similar questions. – vonbrand Feb 26 '13 at 13:52
  • I found the solution in a mailing list. the author says he stumbled over the line when poking around in /etc/pam.d/sshd. I’m afraid that’s all I know. – Frode Feb 26 '13 at 14:14
  • This fixed it for me on ubuntu as well. – Jacob Mar 20 '13 at 1:27
  • Comment this line worked for me on Ubuntu (DigitalOcean) and Debian (local network) over SSH. I've also disable motd. – thiagobraga Jul 22 '15 at 16:06

I have a sheevaplug with Debian. I commented the reported line inserting # and solved the problem.

File to edit in debian:


Line to comment in file:

session    optional     pam_mail.so standard noenv # [1]

Run crontab -e and add output to your cron jobs. If you want to disable emails for just one cron job, you will need to redirect its output to /dev/null by adding > /dev/null 2>&1 at the end of the line.

For example:

* * * * */5 /path/to/command arguments > /dev/null 2>&1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy