How to remove "You have mail" welcome message

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:

unset MAILCHECK

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]