How to Delete Local Mail on Mac and Stop Terminal Notifications

emailmacosterminal

I set up a wayward cron task and accidentally sent a lot of emails to the Mac's local mail server (when opening terminal, it says "You have mail."), they're all junk and I want to remove them. What is the best way to do so?

I have considered a couple of approaches, but I don't want to risk breaking something. Here are those 2 approaches:

  1. simply deleting the file /var/mail/$USER
  2. This approach:

Go to the Finder, hold down the Option key and click the Go menu. You'll see a Library folder in the list. Click that. (You can only see it when you hold down the Option key.)
Within, there's a Mail folder, then v2, then subfolders for accounts. Your old account folder may be there, although I've always experienced it being deleted when an account is removed.

I'm a little unsure about this because I don't see V2, but instead V8, and I have no idea what those files are:

enter image description here

So I am unsure of what to do. The goal is to safely remove any potential junk from my computer, and stop the "You have mail." message from appearing when I start the terminal.

Best Answer

Remove /var/mail/$USER. The other option would remove the actual mails you see in Mail.App, this is for sure not what you want.

If you keep getting mails in Terminal, run less /var/mail/$USER to see which processes are sending them.