Score:3

On Ubuntu server, how can I receive "new mail" notifications on the terminal while logged in?

co flag

I connect to my Ubuntu 20.04.2 LTS server via SSH, and the "You have new mail" notification works properly when logging in, however, if I receive mail while already logged in, I don't get any kind of notification.

I remember this working properly on other Linux systems in the distant past and I can find references online regarding it working for other people but no instructions on how to make it work.

If I receive mail while logged in I'd like the terminal to automatically display a notification message.

Based on searches for possible solutions, I checked the value of the "$MAILCHECK" environment variable and found that it's already set to 60 seconds, so I haven't made any adjustments to it.

I found a package named "mailcheck" that was not installed so I installed it, however, nothing visibly changed. Manually running the "mailcheck" command never outputs anything even when I know I have mail in the mailbox.

Score:4
co flag

I eventually found that there's an environment variable $MAIL that's supposed to be set but (for some reason) wasn't.

So I set it via my .bashrc:

MAIL=/var/mail/username

This resolved the issue.

The "mailcheck" package ended up being irrelevant so I purged it.

The following documents were useful in solving this:

https://www.shell-tips.com/bash/environment-variables/#the-mail-variables-mail-mailpath-and-mailcheck

https://docstore.mik.ua/orelly/unix/upt/ch21_08.htm

ph flag
What about `export MAIL="/var/mail/$USER"` to make it more universal/portable?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.