You have mail, Terminal says

JULY 16, 2022

You have mail, Terminal says from time to time.

There's an internal mail delivery system that certain system services make use of to deliver messages to the user, maybe errors or warnings, that would otherwise be lost. One example is the output of cron jobs; as they run in the background, there's no way to notify the user.

These "mails" are stored at /var/mail/$USER. (You can run echo $USER in Terminal to see what username is being used for the current user.)

Reading your email

The brute force way is to browse the original content of the emails.

cat /var/mail/$USER

A better way is to use the mail command.

# Mail version 8.1 6/6/93.  Type ? for help.
# "/var/mail/nono": 3 messages 3 new
# >N  1 nono@abawrihf  Fri Jul 15 12:26  19/856   "Cron <nono@abawrihf> cd ~/Desktop/some-dir && zip -qr9 ...
#  N  2 nono@abawrihf  Fri Jul 15 12:27  19/856   "Cron <nono@abawrihf> cd ~/Desktop/some-dir && zip -qr9 ...
#  N  3 nono@abawrihf  Fri Jul 15 12:28  19/906   "Cron <nono@abawrihf> cd ~/Desktop/some-dir && zip -qr9 ...
  • Input 2 to show that message, for instance.
  • Input exit to terminate the mail command

Delete existing messages

sudo rm /var/mail/$USER

Then your inbox will be empty.

# No mail for nono