21

I'm using zsh with prezto as my shell with iTerm as terminal app.

I always get the message "You have new mail" when opening a new prompt. I don't have any new mail in Mac Mail and I don't run a mail server.

How can I get rid of this message?

Thanks

1
  • 3
    You have mail in /var/mail - use the mail command to read
    – mmmmmm
    Commented Nov 29, 2014 at 19:05

5 Answers 5

20

It tells you that you have received some mails (for example, because of your configuration of cron).

The best way is to read this mail. Type mail: at least one mail should appear. You can read by typing its number ID. You can also directly delete it (or even multiple mails) by typing d 1-1344 (1-1344 being the range of your new mails' IDs). Leave mail with x.

2
  • 6
    You may need to use q instead of x, to save changes
    – zessx
    Commented Jul 22, 2018 at 13:48
  • 1
    You slipped in an extra 1 digit.
    – 146438
    Commented Sep 17, 2019 at 14:10
15

Whether zsh checks for new mail can be adjusted through the MAILCHECK parameter as described in zshparam(1). It specifies the interval in seconds between checks for new mail, a zero turns off the checks completely. So just put this into your zsh configuration file:

# don't check for new mail
MAILCHECK=0
2
  • 4
    this doesn't work in ~/.zshrc on mac OSX with oh_my_zsh. is there another zsh configuration file? is there a work around? Commented Jun 13, 2017 at 21:49
  • Very late reply, but in case others find this page: you could also try ~/.zshenv if it is not working in ~/.zshrc
    – TJ Luoma
    Commented Feb 5, 2020 at 19:02
10

So apparently some program (probably my MAMP) put an email in

/var/mail/

Deleting this message did the trick...

3
  • 1
    ugh… I'd been seeing that in terminal for so long it felt like it was just its way of saying 'Hello". Nice find.
    – Tetsujin
    Commented Nov 29, 2014 at 19:56
  • 1
    So you feel like trashing the contents of your mailbox is a good idea? Do you also do this in real live?
    – bot47
    Commented Dec 4, 2014 at 6:53
  • 3
    Well the mail in question was more a mistake by a local server. I am on Mac OS and my mails are stored somewhere else. So trashing this file was ok. If your actual mail is stored under /var/mail YOU SHOULD NEVER DO THAT... Commented Dec 6, 2014 at 12:11
9

In case you want to check what those mails actually are before ignoring them, you can read the mails by:

mail

and read one the emails by entering a number, e.g.:

1

and if you have fixed the problem reported by the mails (in my case, the cron jobs are failing due to renaming a folder) and feel comfortable to delete all the mails:

delete *

then quit the program:

q

as shown in following screenshot: enter image description here

0
0

Unsetting (or even changing the value of) MAILCHECK didn't stop the message printed when I open a terminal tab/window. I eventually stumbled on an answer on superuser that enables me to still see this mail when it's convenient, but skip the constant nag message.

In short, create a ~/.forward file and, on a single line, the path of a file you'd like to receive mail in. Later, you can still elect to read the mail with mail -f <new_mail_file>.

If you have more advanced needs, it looks like forward can also specify a script by setting the line to |script_path or "|script_path args". I haven't tried this, but it should make it pretty simple to route messages based on the script that produced them, convert/compact them into a simple summary logline, etc.

You must log in to answer this question.

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