Inserting a Copy of a Message or File
You can insert a copy of any message in your mailbox into the message you're writing. Likewise, you can insert a copy of any text file.
Inserting a Message
Use the following command form to insert a message.
~m number |
In this example, number is the number of the message to be inserted. For example, to send to another user a message that includes a copy of message number 3 from your mailbox list, complete the following steps.
On a new line, type the command ~m 3, and then press Return.
mailx displays the following message.
Interpolating: 3 (continue)
You do not see the text of message 3, but the recipient will. You can continue to compose your message after (continue), or you can send it as is.
To see the complete message, interpolation included, type the command ~p.
Inserting a File
You can also insert a copy of any text file into a message. As you are writing a message, use the following command form.
~r filename |
For example, to insert the file outline in the current message, type the following command.
& ~r outline |
Replying to a Message
Reply to mail at a mailx prompt by typing the following command.
r number
If you omit the message number, mailx replies to the current message.
For example, to reply to the sender of message 2, type the following command.
& r 2 |
mailx automatically addresses your message and supplies an Re: Subject: line that echoes the original Subject: line. Send your reply as you would with any other message.
R is a variant of the reply command that sends your reply to all recipients of the original message as well as to its sender. Use this command only when absolutely necessary, to avoid generating "junk mail."
Note - You can insert a message into your reply as shown in the previous section. To insert a copy of the message to which you are replying, type the command ~m without a message number.
Saving and Retrieving Messages
In addition to sending and receiving messages, you might also save and retrieve them for later use. In mailx you can save messages by appending them to regular text files. You can also append messages to special files called folders. Both methods are discussed subsequently.
mailx makes a distinction between saving messages and copying them. Saving removes a message from the mailbox and appends it to a file or folder. Copying leaves a message in the mailbox and appends a copy to a file or folder.
Saving and Copying Messages in Files
To save a message into a file, use the following command form at the mailx prompt.
s number filename |
where number is the number of the message to be saved and filename is the file where you want to save the message. For example, to save message 3 into a file called ~/notes/finance, you would type:
& s 3 ~/notes/finance |
Remember that in a path name, the ~ represents your home directory.
You can also save several messages at once to the same file. For example, to save messages 3, 5, 6, 7, and 8 to ~/notes/finance, type the following command.
& s 3 5-8 ~/notes/finance |
If the file you specify does not exist, mailx creates it. If the file does exist, mailx appends the message you are saving to the end of the file.
Saving a file removes it from your mailbox. mailx displays an asterisk (*) next to the header of any message than has been saved.
To leave the message in your mailbox while appending it to another file, use the copy command, as follows:
& c 3 ~/notes/finance |
Saving and Copying Messages in Folders
You can avoid typing full path names to files if you save or copy messages to mail folders. Folders are special files that are stored in a folder directory.
The advantage of saving or copying messages to folders is that your messages are automatically stored in the same directory, where they are easily accessible without typing long path names.
Setting the Folder Directory
To use folders, you must first set up a folder directory. Follow these steps to set up a folder directory.
Create a directory by using the mkdir command.
For example, if you wanted your folder directory to be called Messages, you would first create the directory:
$ mkdir Messages
Edit the .mailrc file in your home directory (which contains mailx options) to set the folder directory path.
Edit the folder variable to include the full path name of your newly created folder directory. For example:
set folder=/home/austin/rose/Messages
Or use the C shell shortcut ~ to specify your home directory.
set folder=~/Messages
Now your folder directory is set to receive messages that are saved in folders. The change to the .mailrc file becomes effective the next time you start mailx.
Designating Folders
You use the same commands to save or copy messages into folders as into files, except that the folder name is preceded by a plus sign (+) instead of a path name. The + tells mailx that the folder is to be kept in the folder directory (Messages).
For example, to save message 3 to a folder called projects, type:
& s 3 +projects |
mailx interprets this command as "save message 3 into ~/Messages/projects." If the folder doesn't already exist, mailx creates it.
Copy the message into a folder by typing:
& c 3 +projects |
Sending a Message Directly to a File or Folder
You can send copies of your messages directly to one of your files or folders. To send a copy to a folder, simply type the folder name in either the Cc: or the Bcc: field. Sending a copy to a file is similar, but you must include the full path name.
Reading Messages in Files and Folders
To read messages that are saved in a file, use the command form:
mailx -f filename |
In the previous example, you would read the file ~/memos/finance by typing:
$ mailx -f ~/memos/finance |
You can read messages that are saved in a folder with a similar command--just use the + instead of a path name. For example, to read the messages in the folder projects, you would type:
$ mailx -f +projects |
This command starts mailx in the file or folder that you have designated. Only headers for the messages in the file or folder are displayed. Select a message to read by typing its number at the mailx prompt, and then press Return.
You can also work on mail folders within the mailx program. To see a list of your folders, type this command at a mailx prompt:
& folders |
To switch from your mailbox to a folder, use the command form:
& folder +foldername |
To return to your mailbox, type this command at a mailx prompt:
& % |
To return to the previous folder, type:
& # |