[solved] How To Delete Mail from Terminal in macOSWritten by Alex Thursday, 12 October 2017 14:46
If you show message in terminal “You have mail” you can delete all messages
sudo rm /var/mail/<your-username>
If you want send mail via terminal use commands:
mail -s "hello" "firstname.lastname@example.org" <<EOF hello world EOF
You can access the mail by simply using the command
This launches you into Mail, and it will right away show you a list of messages that are stored there. If you want to see the content of the first message, use
This will show you the content of the first message, in full. You'll need to scroll down through the message to view it all, by hitting the down-arrow key.
If you want to jump to the end of the message, use the
If you want to abort viewing the message, use
To view the next message in the queue use
... assuming there's more than one message.
You can also view a specific message by just inputing its number at the ? prompt. 3, for instance, will show you the content of the third message (if there are that many in there).
Use the command (at the ? command prompt )
d [message number]
To delete each message when you are done looking at them. For example, d 2 will delete message number 2. Or you can delete a list of messages, such as d 1 2 5 7. You'll see the message numbers in the list of messages mail shows you.
To delete all the messages, from the mail prompt (?) use the command d *.
As per a comment on this post, you will need to use q to quit mail, which also saves any changes.
If you'd like to see the mail all in one output, use this command at the bash prompt (i.e. not from within mail, but from your regular command prompt):
And, if you wish to delete the emails all in one hit, use this command
sudo rm /var/mail/<username>
In my particular case, there were a number of messages. It looks like the one was a returned message that bounced. It was sent by a local Wordpress installation. It was a notification for when user "Admin" (me) changed its password. Two additional messages where there. Both seemed to be to the same incident.
Leave a comment
Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.
Latest from Alex
- How to change your version of your Mac OS?
- [solved] How to remove Gutenberg styles from frontend?
- [solved] Tired of the message “Hola! Please activate your copy of Visual Composer to receive automatic updates.”?
- New Magento Enhancements Available Today [27 March 2019 ]
- How to change tag count limit in woocommerce widget?