In addition to sending and receiving letters, you may also want to save and retrieve them for later use. In mailx you can save letters by appending them to regular text files; you can also append letters to special files called folders. Both methods are discussed below.
mailx makes a distinction between saving letters and copying them; saving removes a letter from the mailbox and appends it to a file or folder; copying leaves a letter in the mailbox and appends a copy to a file or folder.
s number filename
where number is the number of the letter to be saved and filename is the file where you want to save the letter. For example, to save letter 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 letters at once to the same file. For example, to save letters 3, 5, 6, 7, and 8 to ~/notes/finance, you would type:
& 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 letter you are saving to the end of the file.
The advantages to saving or copying letters to folders is that your letters are automatically kept together in the same directory, where they are easily accessible without typing long pathnames.
To use folders, you must first set up a folder directory. This is a two-step process:
First, make the directory using the mkdir command.
For example, if you wanted your folder directory to be called Letters, you would first make the directory:
$ mkdir Letters
Here you need to edit the
variable to include the full path name of your newly created folder directory.
or, using the C shell shortcut ~ to specify your home directory.
You use the same commands to save or copy letters 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 (Letters).
For example, to save letter 3 to a folder called projects, type:
& s 3 +projects
mailx interprets this command as meaning "save letter 3 into ~/Letters/projects." (If the folder doesn't already exist, mailx will create it.)
Copy the letter into a folder by typing:
You can send copies of your letters 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.
mailx -f filename
Using the example above, you would read the file ~/memos/finance by typing:
$ mailx -f ~/memos/finance
You can read letters saved in a folder with a similar command--just use the + instead of a pathname. For example, to read the letters in the folder projects, you would type:
$ mailx -f +projects
This command starts mailx in the file or folder designated. Only headers for the letters in the file or folder are displayed. Select a letter to read by typing its number at the mailx prompt and pressing Return.
|& folder +foldername|
To return to your mailbox, type this at a mail prompt: