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”:
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
- Type
$ man mail
into the Terminal - History of mail, Mail, mailx & nail
- mailx & mail on Wikipedia