Text-based mail

When you login to the system, you are informed by the system if you have mail on the local system. You can read your mail by simply typing mail. The mail program will display a numbered list of new messages with their subject headers. To read a message type n where n is the number of the message you want to read. To delete the message numberedn type d n. To save a message in a file use the s command. To exit out of the mail and save all messages, without deleting, in the file mbox in your home directory, use q. To reply to a mail use the Reply or R command. There is also a help command in the mail program.

If you want to send mail to any user then you need to type mail <user_name>. It will then prompt you for a subject of the mail message. You can leave it blank if you wish. After you have finished typing the message, press Ctrl-d to send it. While typing the message you can only edit the current line. However you can invoke the vim editor any time by typing $\sim$v on a line by itself. This puts your current in a temporary file and allows you to edit the message using your default editor. After you are finished typing, exit vim and press Ctrl-d ends the message.

A mail program with a more convenient interface is mutt. It is available on all Linux systems. The mail amd mutt programs are useful in scripts, which we will learn more about in Chapter 6.