199

Any idea why my Mac terminal says:

You have mail in /var/mail/lofye

How can I make it stop saying that every time I open terminal?

1

8 Answers 8

197

Somehow you've had a script or something similar deliver mail to your account on your local machine which is stored in /var/mail/$USER

You can either remove the file /var/mail/$USER which will remove the alert that you have mail (as it will alert you if that folder is present and/or has unread messages) or you can use mail to read the messages before deleting them.

7
  • 29
    Thanks for the tip. Turns out a CRON is mailing me... 36,061 times :( Deleted with command: d 1-36061
    – lo_fye
    Aug 19, 2009 at 15:15
  • 8
    See this question. superuser.com/questions/7677/stop-cron-from-emailing-me Aug 19, 2009 at 16:45
  • You can direct the cron output to /dev/null to avoid the mail.
    – Chris Nava
    Aug 19, 2009 at 19:18
  • 1
    Where is this default text located on Mac OS X? I'd like to leave it active but change the message.
    – user114114
    Jan 17, 2012 at 21:20
  • 2
    xkcd.com/1728 Funny because it's true :)
    – camelBase
    Jan 20, 2017 at 5:37
55

Type mail to view the mail. I believe d deletes it.

5
  • 2
    * d should delete everything.
    – lyarwood
    Aug 19, 2009 at 15:11
  • 3
    When using mailx d* will delete everything. Mail itself won't. Aug 19, 2009 at 15:46
  • 8
    Doing mail and then d * removed all mails for me on Mac OS X.
    – yagooar
    Nov 13, 2014 at 13:11
  • 2
    See apple.stackexchange.com/questions/28745/… to delete all messages. Sep 24, 2020 at 18:43
  • 5
    This answer did not work for me. Thanks to @ShaunDychko's link, I found the reason: Make sure do to exit with q after the d * command, only that saves the changes to disk.
    – not2savvy
    Mar 8, 2022 at 21:36
17

There are several ways to remove it. The simplest is:

> /var/mail/<whatever_user>

You need to include the '>'

1
  • 9
    That wipes out the received mail for that user.
    – vonbrand
    Mar 31, 2013 at 14:33
6

Open mail and then put in d * and press Enter. The d command means delete and the * selects all mails in the list.

0
2

I'm willing to bet it's because there are files in that folder.

Have you actually looked at the contents of the folder? If there is something in there, it will more than likely give you an idea of what caused it, and how to prevent it in the future.

From the terminal:

cd /var/mail/lofye
ls

If you don't have mail, you won't see the message (there's not even a folder for my username under mail on my mac).

1
  • 4
    /var/mail is a directory, and loyfe is the file within it. To view the file, one could less /var/mail/loyfe. Jun 21, 2013 at 13:56
1

If you are running ClamAV for Mac this is a known issue. The system mails you after each update and scheduled scan.

0

There is a trick way.

  1. completely empty the email file

: > /var/mail/$User

  1. change the attribute of email file

sudo chflags schg /var/mail/$User

As except "root", no one can change this file.

Then the annoying "You have mail" gone away.

-3

I was able to just create a .hushlogin and I've a clean Terminal now.

$ touch .hushlogin
1
  • 5
    This prevents many messages from being displayed, not just the new mail message. This could be dangerous as there are certain other warnings the user would miss out on. Jun 21, 2013 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .