########################################################################### # Mailx Notes # # Anuradha Weeraman, 20 August 2000 # # $Id: mailx.txt,v 1.2 2004/06/02 21:23:35 anuradha Exp $ # ########################################################################### Syntax : mail [-iInv] [-s subject] [-c cc_addr] [-b bcc_addr] to-addr ... [- sendmail_options ...] mail [-iInNv] -f [name] mail [-iInNv] [-u user] Examples : mail addie mail melissa@misty.acme.com mail friend@beta mail curly larry moe melissa@misty.acme.com mail curly larry moe < notice mail -s "Do you want free money?" addie Pressing ^D while entering the message will send it off to the recipients. Typing a period (.) on a single line by itself will do the same. While typing a message, if you feel to discard it, press ^C twice and the contents will be dumped to 'dead.letter' and program is ended. mail -v -s "New time for the meeting" melissa@misty.acme.com As the email is being typed, mail understands certain commands preceded by the tilde escape character. These commands have to be typed on the lines by themselves. These commands are : COMMAND DESCRIPTION ~? help: display summary of tilde escapes ~b address add addresses to the "Blind Copy" line ~c address add addresses to "Copy" line ~d read in contents of "dead.letter" file ~e invoke text editor ~f messages read in old messages ~h edit header lines ~m messages read in old messages ~p display (print) current message ~q quit (same as pressing intr key twice) ~r file read in contents of a file ~s subject change "Subject" line ~t address add new addresses to the "To" line ~v invoke the visual editor (usually same as ~e) ~w file write current message to a file ~! command execute shell command ~| command pipe current message through filter By using "~| fmt" the contents of the letter can be nicely formatted to fit the width of the screen. Emails can also be sent to files rather than specific user ids. This is a good way to keep records. Use the / in specifying the filename. mail curly larry moe ./stooges Mail can be also sent to programs. If you have the program "broadcast" you can send a message to everyone on the system by mail '|broadcast' There are three ways to know if you have received any mail. 1. Type 'mail'. This will start the mail program. If you have any mail, it will be displayed. 2. If you have the program 'from', it will display headers of your email. 3. You can activate the program biff by typing 'biff y' and it will notify you of any email on arrival including a summary. Mail is usually stored in "/usr/spool/mail/userid". On some linux systems this directory is symlinked to "/var/spool/mail/". This is known as the system mailbox. When you read mail, the mail is transferred to a file called mbox in your home directory. Mail can be forced to open another file other than the system mailbox using the -f switch. mail -f /home/anuradha/mbox THE MAIL COMMANDS ABBREVIATIONS FULL NAME DESCRIPTION Stopping Mail q quit quit mail x exit quit mail, neglect any changes Help ? - display summary of important commands l list list names of all available commands Headers h headers display header summaries z - show next set of header summaries z- - show previous set of header summaries Displaying Messages + - display the next message - - display the previous message - display the next message number - display message #number n next display the next message p print display (print) messages to top display top few lines of messages Replying and Mailing m mail send new message to specified userid r reply reply to sender & all other recipients R Reply reply to sender only Processing a Message d delete delete messages dp - delete current msg, display next msg e edit use text editor on messages pre preserve keep messages in system mailbox s save save messages to specified file u undelete undelete previously-deleted messages w write same as s, only do not save header Shell Commands ! - execute a single shell command sh shell pause mail, start a new shell When using ~m and vi to reply to a message, type ":%s//>> /" to include >> at the beginning of the lines of the message and continue with your message. To type a new message, use 'm'. m harley MESSAGE LISTS To delete messages 3 to 5 : d 3-5 To display all the messages from root : p root To delete all messages : d * Specification Meaning . [a period] the current message n message number n n-m all messages from n to m inclusive ^ [a circumflex] the first message $ [a dollar sign] the last message * [an asterisk] all messages userid all messages from specified userid /pattern all messages containing pattern in subject :n all new messages :o all old messages :r all messages that have been read :u all messages that are still unread Command Meaning p . display the current message p 3 display message 3 p 3-5 display messages 3 through 5 inclusive p ^ display the first message p $ display the last message p * display all messages p harley display messages from userid harley p /hello display messages with "hello" in subject p :n display new messages p :o display old messages p :r display messages that have been read p :u display messages that are still unread Customizing mail using the .mailrc file Syntax : alias name address ... alias melissa melissa@misty.acme.com alias lprp '|lpr -p' alias workgroup al bill carol dave emily melissa The last command makes a single alias to several mail boxes Option Meaning ask prompt for the "Subject" line of each message askcc prompt for the "Copy" line of each message autoprint after deleting, display the next message verbose show details of mail delivery (same as -v option) Replyall reverse the sense of the r and R commands The set and unset commands turn an option on or off respectively. set ask unset askcc