Mysterious “You have new mail” in OS X Terminal

Recently I discovered a mysterious message showing up in every new Terminal window I opened under OS X. The notice simply read “You have new mail”:

You Have New Mail in OS X Terminal

First I thought this was something that had been put in the Terminal’s startup message (called motd – Message of the Day, which can be edited with “$ pico /etc/motd”). However, this was not the case.


KTJGPTNURUHF
Fortunately a short web-search delivered the answer and solution to this strange occurrence: the message is a part of the built-in Unix mail processing system, called “mail” or “mailx”.

This application provides a functionality called “sendmail” which is commonly used in website development to generate an e-mail, for example in a contact form. And this was also the reason why I had that suspicious mail notice in my Terminal.

How to get rid of those messages

By using the follwing Terminal command, you will receive an overview of the mail messages – namely the mail inbox:

$ mailx #launches the unix mail app Mail version 8.1 6/6/93.  Type ? for help. "/var/mail/user": 1 message 1 unread >U  1 MAILER-DAEMON@...  Mon Feb  8 21:41  81/2505  "Undelivered Mail Returned to Sender" ?

 

The prefix “U” stands for “Unread”. There are other prefixes such as “N” = New and “> ” = Read.
From here you can use now several commands to handle the messages (display the list using “?”):

? ? [RETURN]
Command
Description
t 
type messages
n
goto and type next message
e 
edit messages
f 
give head lines of messages
d 
delete messages
s 
file append messages to file
u 
undelete messages
R 
reply to message senders
r 
reply to message senders and all recipients
pre 
make messages go back to /var/mail
m 
mail to specific users
q
quit, saving unresolved messages in mbox
x
quit, do not remove system mailbox
h
print out active message headers

 

Most commonly you might want to read the message(s) and/or delete them. To do so, type:

? message-id [RETURN] #Use ctrl+v to skip through the message

Afterwards simply use the following command to delete a message:

? d message-id [RETURN]

Further reading

  1. Type “$ man mail” into the Terminal
  2. History of mail, Mail, mailx & nail
  3. mailx & mail on Wikipedia

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting