Shell – Hide “You have old mail” message when logging into shell

dovecotemailmotdpostfixshell

I have a mail system set up on my server (Postfix + Dovecot) that I use for personal and sys-admin email. Every time I login via shell (for all of my accounts), the message "You have old mail." is displayed below the MOTD modules I've configured.

I can't delete or move (most of) my read mail elsewhere, but I'd like to hide this message; it's pointless and clutters my MOTD. I'd prefer to keep the "You have new mail." message if possible, but I'm willing to lose it if that's what it takes.

I don't think this message is from a MOTD module, and it shows up on both SSH and local.

How can I hide or remove the "You have old mail." message when logging into shell?

Best Answer

It is probably generated by the PAM pam_mail.so module.

Edit /etc/pam.d/login en comment out the line that looks like:

session    optional   pam_mail.so standard

Alternatively, keep the line but remove standard if it's there, and add nopen to the end.

It may be necessary to do the same in the /etc/pam.d/sshd file.

See man pam_mail for more information.

Related Question