Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1331 / 47 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 26:

Electronic mail: clients

< Лекция 25 || Лекция 26: 12345 || Лекция 27 >

Using folders

mutt can handle multiple folders. It defaults to your incoming mail folder, sometimes called an inbox. On BSD, it is a single file in /var/mail with the same name as your user ID. We saw that above at the top of the index screen: mine is called /var/mail/grog.

mutt stores other folders as single files in the directory ~/Mail, in other words a subdirectory of your home directory. Many MUAs use this method, but not all of them: some use the directory ~/mail instead. By default, when you write a mail message, the outgoing message gets copied to a file in this directory. In the previous section, the Compose menu contained the pseudo-header Fcc: =jbozza. This refers to the file ~/Mail/jbozza: mutt uses the shorthand = to refer to the mail directory.

To keep incoming mail, you use the s (save) command, which sets a default folder name from the name of the sender, the same name as when saving sent messages. You can thus reply a message, saving a copy in the folder, then save the original message, without explicitly mentioning a folder name at all.

To read messages in a folder, you can tell mutt to read it directly on startup:

$ mutt -f =fred

Alternatively you can change folders with the c command.

Deleting messages

Once you've finished reading a message, you may want to delete it. You can do this by entering d. The D fag appears on the left of the line, but nothing much else happens. The message doesn't get deleted until you exit mutt, or until you enter $.

When you save a message to a folder, it is automatically deleted from the current folder. If you don't want to do that, or if you have accidentally deleted a message, you can undelete it by entering u.

Finished reading a thread? You can delete the entire thread by entering ^D (Control-D) .

Tagging messages

We've seen that you can delete an entire thread with a single keystroke. What about other operations on multiple messages? There are a couple of useful possibilities. You select the messages under the cursor by entering t. In the example above, messages 51 and 64 are tagged. You can reply to all tagged messages in one reply by pressing ;r. In this case, mutt ignores the message under the cursor and replies only to the tagged messages, reply to all people on the To: headers of each message. Similarly, you can do a group reply to all the tagged messages with ;g, and you can delete thcode all with ;d.

Configuring mutt

We've already see that there are a lot of things that you can change about mutt's behavior. They are described in a file ~/.muttrc (the file .muttrc in your home directory). Here are a few of the more interesting entries in my .muttrc:

source /usr/local/etc/Muttrc

The file /usr/local/etc/Muttrc contains the default definitions for running mutt. Put this at the top of your .muttrc file so that the following definitions can override any previous definitions. This file also contains a large number of comments about how to set each variable, and what it does: it's over 3,000 lines long.

source ~/.mail_aliases

~/.mail_aliases is the name of an alias file, a file with abbreviations for frequently used mail addresses. We'll look at them on page 484.

set alternates="greg.lehey®auug.org.au|groggy®|grog@|auugexec@|core@free"

This string is a regular expression that mutt uses to determine whether mail is addressed to me. If it matches, it sets one of the fags discussed above: + if the message is sent only to me, T if I am mentioned on the To: header, and C if I am mentioned on the Cc: header.

my_hdr Organization:  LEMIS, PO Box 460, Echunga SA 5153, Australia
my_hdr Phone: +61-8-8388-8286

These lines and more become headers in messages I send; you can see them in the examples above.

set editor=emacsclient

This line overrides the default editor in EDITOR. We've already seen the use of emacsclient.

set pager_index_lines=10

This tells mutt to keep ten lines of the index when displaying a message. Figure 26-8 shows what the display looks like when this is set. Clearly this isn't much use with a 25 line display. If, on the other hand, you have a larger X display, it can be very convenient to have a selection of the index at the top of the screen.

set hdr_format="%4C %Z %{%d-%m-%Y} %-20.20L %-15.15t (%4l) %s"  # format of the index
set status_on_top  #put the status bar at the top
set sort=threads
set date_format="%A, %e %B %Y at %k:%M:%S %Z"

These variables tell mutt how to display the message index. They account for the difference in layout (but not color) between the default screen and the custom screen. hdr_format is a printf-like format string that describes the layout, status_on_top reverses the information lines at the top and bottom of the display, sort=threads sets a threaded display by default (you can change it by pressing o), and date_format is set to international conventions.

Reading a message with pager index lines set

Рис. 26.8. Reading a message with pager index lines set
set edit_hdrs  #let me edit the message header when composing
set fast_reply  #skip initial prompts when replying
set attribution="On %d, %n wrote:"
set charset="iso-8859-15"  #character set for your terminal
set sendmail_wait=-1

These variables specify how to write and reply to mail messages:

  • edit_hdrs tells mutt to include the headers in the message you write, as shown in the preceding examples.
  • fast_reply tells mutt not to prompt for a number of the headers. This is faster, and it's not necessary when you have the headers in the message you're writing.
  • attribution describes the format of the attribution at the beginning of a reply, the text On Friday, 20 Septcodeber 2002 at 8:13:44 -0500, Jaime Bozza wrote: in the example above.
  • charset specifies the character set to use for the message. This should correspond to the character set of the fonts on your display, otherwise things may look strange. ISO 8859-15 is the new Western European character set that includes the character for the Euro. You'll still see many message with the older Western European character set, ISO 8859-1, which is otherwise very similar.
  • Finally, sendmail_wait tells mutt whether it should wait for the mail to be sent before continuing. This can take some time if your MTA has to perform numerous DNS lookups before it can send the message. Setting this variable to -1 tells mutt not to wait.
ignore *
unignore   From: Date: To: Cc: Subject: X-Mailer: Resent-From:
hdr_order  Date: From: To: Cc: Subject: X-Mailer: Resent-From:

These specifications tell mutt to ignore all headers except for specific ones, and to sort them in the order specified, no matter what order they occur in the message.

Colors in mutt

Finally, .muttrc contains definitions to describe the color of the display. Many of these are personal preferences, so I'll just show a couple. Each definition specifies the foreground color, then the background color:

color normal black white

This is the basic default color, overriding the reverse video shown above.

color hdrdefault brightblack white
color quoted brightblack white

This tells mutt to highlight headers and quoted text in bold.

color status black yellow

This tells mutt to display the status bars in black on a yellow background.

color index blue white FreeBSD

This tells mutt to display any messages with the text FreeBSD in blue on white, like messages 48 and 49 in the example above.

There are many more variables you can set to customize your mutt display. Read /usr/local/etc/Muttrc for more details.

Mail aliases

You'll find that some people have strange mail IDs: they are unusual, confusing, or just plain difficult to type. Most MUAs give you the option of setting up aliases, short names for people you often contact. In mutt, you can put the aliases in the ~/.muttrc file, or you can put them in a separate file and tell mutt when to find them in the ~/.muttrc file, as illustrated above. The aliases file contains entries like this:

alias questions FreeBSD-questions@FreeBSD.org (FreeBSD Questions)
alias stable FreeBSD Stable Users <FreeBSD-stable@FreeBSD.org>

The format is straightforward:

  • First comes the keyword alias. Aliases can be placed in ~/.muttrc,so the word alias is used to distinguish them from other commands.
  • Next is the alias name (questions and stable in this example).
  • Next comes the mail ID in one of two forms: either the name followed by the mail ID in angle brackets (<>), or the mail ID followed by the name in parentheses (()).

In mutt, you can add aliases to this file automatically with the a command, which offers default values relating to the current message.

< Лекция 25 || Лекция 26: 12345 || Лекция 27 >