How to get rid of the “You have mail” Unix message

In the process of using Unix or Linux on the command line, you may have encountered the “You have mail” message. It can be encountered on Linux servers or on local desktop environments, such as Mac OS X. While somewhat alarming and confusing, especially the first time, this is generally a fairly trivial message and easy to remove. This post will look at what the *nix mail application does, and how you can remove the “new mail” message from OS X.

What is mail?

mail is the built-in email client for Unix and Unix-based operating systems, to be used directly from the command line. Its origins dating back as far as 1978, this application was one of the first email clients, distributed as part of the first research version of Unix released. The application allows for checking and sending email directly from the command line:

echo "How about 1pm?" | mail -s "Let's get lunch today" nick@sunlightmedia.org

 

The above command will send an email with the content of “How about 1pm?” and a subject of “Let’s get lunch today” to nick@sunlightmedia.org.

To check for mail, you can simply enter:

mail

 

If there is new mail, the application will display a list of the emails, their subject, date and other info — essentially like a proto-email inbox:

If there is no new mail, the command line will simply read: No mail for [user], where [user] is the name of your computer system or server.

Why is mail being sent to the operating system email client?

If you have not specifically and intentionally set up mail as your primary email client, the “You have mail” message is most often encountered when installing applications or other packages from the command line. Sometimes software developer’s releases will include a function to update the system of a completed installation or relevant notes on the release. When there is new mail, this message will appear every time you open a new terminal window or login to the system, which can get quite annoying.

How to remove the “You have mail” message

To remove the “You have mail” message, open the Finder application, then select “Go to folder…” from the “Go” dropdown menu (Shift + Command + G). From there, type in var/mail/[user], where [user] is the username of your system (in my case, air):

(Note: if you try to do this when there is no new mail, Finder will say “The folder can’t be found.”)

Hit “Go”, and the Finder application should display a mail file in the mail directory, with your username as the filename.

Simply delete this file, empty your trash and open a new terminal window. You should no longer see “You have  mail” display. You can also verify this by entering mail and it should display No mail for [user].

As an alternative to the method above, you can also remove the mail file from the command line.

Navigate to your home directory (from any directory you’re in):

$ cd

 

Go back 2 directories to the root directory:

cd ../..

 

Go to the mail directory:

cd var/mail/

 

If you type ls it should list the same mail file we removed from the Finder. To remove it simply type rm [filename] . Make sure you are removing the right file, as there is no way to retrieve it from the Trash bin via this method.

Resources

Post a Comment

Comments are moderated. Your email is kept private. Required fields are marked *

© 2018 Sunlight Media LLC - Web Design Company