How to Use Mail from Terminal in MacOS

Hi folks,

It’s been a while. Here’s a quick post on how to read local mails on your MacOS. This can come in handy if you have cron jobs running on your machine for example which send mails and you want to read the mails sent.

To open mail, open a terminal and run the command

mail

You will see the number of messages, number of unread messages and one line per message, including sender, time of receipt, and mail title. There will be a number shown for each mail starting from 1, then 2, etc.

To read a single mail, say the first 1, just type 1.

Then you can go up and down the mail by pressing Enter, or ctrl + B to go up a page and ctrl + F to scroll down a page.

Once you reach the end of the mail the prompt will change to ?

You can delete the mail by pressing

d <mail number>

To save your changes to mail, e.g. deletion, etc. press the command

q

To exit mail without making any changes to number of read mails, etc, press command

exit

To read about mail command in general, enter the command

man mail

That’s all for now, happy mailing.

How to cleanly remove Exim 4 on Ubuntu

Run the following command:

apt-get remove exim4 exim4-base exim4-config exim4-daemon-light

All your configs stay on the server so that you can easily get mailing running again by installing it:

apt-get install exim4

Source

exim – How to cleanly remove Exim4 mail server on Ubuntu – Stack Overflow. http://stackoverflow.com/questions/12061358/how-to-cleanly-remove-exim4-mail-server-on-ubuntu

How to Send Email in Terminal

In this article I demonstrate how to send emails from the terminal of an Ubuntu machine. It’s assumed you have a Mail Transfer Agent like Exim 4 or Postfix set up.

 echo "<message goes here>" | mail \
 -s "<subject goes here>" <to email address>

Sources

How to send email from the Linux command line – Simple Help. http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/