1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Chapter-26-Electronic mail-clients ppt

19 377 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 19
Dung lượng 1,25 MB

Nội dung

2Apr il 2003, 17:00:47 The Complete FreeBSD (mua.mm), page 469 26 Electronic mail: clients In this chapter: • Mail, for mats • Mail user agents • Files,folders or director ies? • Replying to a message • Using folders • Deleting messages • Tagging messages • Configur ing mutt • Mail aliases • Mail headers In this chapter: • Mail, for mats • Mail user agents • Files,folders or director ies? • Replying to a message • Using folders • Deleting messages • Tagging messages • Configur ing mutt • Mail aliases • Mail headers Electronic mail,usually called email, e-mail or simply mail,isamethod of sending messages to other people on the Net. As with other network services, there are twoparts to mail software: • The part of the mail system that most users knowisthe client, the Mail User Agent, or MUA,the program that interacts with the user and handles incoming and outgoing mail. In this chapter we’ll look at my favourite MUA, mutt,and we’ll briefly touch on what others are available. • The server part is the Mail Transfer Agent,orMTA.Asthe name suggests, it is responsible for moving mail from one system to another.We’ll look at MTAs in the next chapter,Chapter 27, Electronic mail: servers. Mail, formats Email is defined by a number of Internet standards, the so-called RFCs, or Requests For Comments.You can browse the RFCs at http://www.faqs.org/rfcs/.Here are the most important ones. • RFC 2821 is a recent update to the venerable RFC 821, which dates from the early 1980s. It defines the Simple Mail Transfer Protocol or SMTP.Itspecifies howto send mail round the network. For most people it’snot very interesting, but it does impose some restrictions such as the basic line length limit. Apart from this problem (which Microsoft abuses), most mail systems adhere to SMTP. mua.mm,v v4.12 (2003/04/02 04:07:59) 469 Mail, for mats 470 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 470 • Similarly,RFC 2822 replaces RFC 822. It defines the basic format of a mail message. It defines the headers (To:, Cc:, Subject: and so on) and a simple body made up of US-ASCII text, the message itself. This was fine for when it was written, butitcan’thandle the more complexformats used nowdays, such as images, binary files or embedded messages. It also can’thandle non-US character sets, which causes problems in particular in countries likeRussia, Israel and Japan. • RFC 2045, RFC 2046, RFC 2047, RFC 2048 and RFC 2049 together describe the Multipurpose Internet Mail Extensions,better known as MIME.Theydefine howto encode non US-ASCII text and attachments so that theycan be represented in ASCII and hence sent by RFC 2822, and also howtodivide the single RFC 2822 body into multiple parts using ASCII separators. MIME is one area in which UNIX is weak. ManyUNIX users consider themselves Real Men who don’tneed these fancytoys. This is a pity.Incountries likeGermany, people can get by with ASCII, but that doesn’twork in Japan, Israel or Russia. In case you’re wondering, German has sevenspecial characters Ä, Ö, Ü, ä, ö, ü and ß. ßis lower case only.There is a national standard defining howtorepresent these characters in US-ASCII: replace the characters with Ae, Oe, Ue, ae, oe, ue and ss respectively. There are plenty of good MIME-aware mail readers available for UNIX. It’sagood idea to use one. On the other hand, if your target audience typically does not use MIME-aware mailers, you should probably avoid sending MIME messages. Mail user agents A mail user agent is a program that interfaces between the user and the mail system. It allows the user to read, forward and reply to incoming mail, and to send his own mail. Beyond that, it usually has facilities for creating and maintaining folders,where you can keep receivedmail messages. Formost UNIX MUAs, a folder is the same thing as a file, butsome MUAs, which we won’tdiscuss here, keep mail messages as individual files, and the folder corresponds to a directory. mail The oldest MUAyou’re likely to meet is mail.It’savery basic, character-oriented program, but nevertheless it has its advantages. You can use it in scripts to send mail. Forexample, if you have a job running and producing copious output, where you want to save the output, you might normally write something like: $ longjob 2>&1 > logfile This command runs longjob.The sequence 2>&1 redirects the error output to the standard output, and the > writes them to the file logfile.While this is a good way to solvethe problem, you might find that you have a lot of such jobs, or that you tend to forget the log files and leave them cluttering up your disks. An alternative istosend yourself mail. Youcan do this with the following command: mua.mm,v v4.12 (2003/04/02 04:07:59) 471 Chapter 26: Electronic mail: clients 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 471 $ longjob 2>&1 | mail me In this case, me is your user ID. When the job finishes, you get a mail message with the output of the commands. cron (see page 151) uses this method to send you its output. Other MUAs mail has a number of limitations: it can’tdeal very well with long mail messages, it’s difficult to keep an overviewoflarge quantities of mail, likemost people seem to accumulate, and it can’thandle MIME. Manymore sophisticated mailers have been written since mail.Some of the more popular ones, which are also available in the Ports Collection, are: • elm is one of the oldest full-screen mailers. Its age is showing: it has a fewannoying problems that makeitless desirable nowthat there’sachoice. • pine is not elm—that’swhat the acronym stands for.It’squite like elm,nonetheless. • mutt is also similar to elm and pine.It’smycurrent favourite, and we’ll look at it in the next section. • exmh is built on Rand’s mh MUA. Some people likeit, but it seems relatively easy to configure it to mutilate messages. • xfmail is an X-based mailer,which you might prefer to the text-based mailers we’re talking about here. • sylpheed is a more recent X-based mailer.You may prefer it to xfmail. Files, foldersordirectories? There are twoschools of thought about howtostore mail: • Traditional MUAs represent folders as files. Theystore all the messages in a folder in that single file. This is sometimes called the mbox method. mail, elm and pine do it this way. • Other MUAs, including exmh, xfmail and sylpheed,represent a folder as a directory. Each message in the folder is then a file by itself. • mutt can use either method, but the default is the mbox method. Which method should you use? Both have their advocates. The directory and file approach is more robust (if you trash a file, you only lose one message, not all of them), and it enables you to have the same message in multiple folders. On the other hand, it also imposes a lot higher overhead. Current versions of ufs,atleast on FreeBSD, have a default block size of 16 kB and a fragment size of 2 kB. That means that all files have a length that is a multiple of 2 kB, and so the average waste of space is 1 kB. In addition, each file uses an inode. If you have a lot of mail, this can add up to a lot of wasted space. Forexample, I currently have 508,649 savedmail messages, which takeupatotal of 2.1 mua.mm,v v4.12 (2003/04/02 04:07:59) Files,folders or directories? 472 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 472 GB, almost exactly 4 kB per message. If I stored them in a directory structure, I would lose about another 500 MB of space, or 25%. The file system on which the messages are stored is 9.5 GB in size and has 1.2 million inodes; nearly half of them would be used for the mail messages. mutt In this section, we’ll takeadetailed look at mutt.Start it by typing in its name. Like most UNIX mailers, mutt runs on a character-oriented terminal, including of course an xterm.We’ll takealook into my mailbox. By default, when starting it up you get a display likethe one shown in Figure 26-1. Figure26-1: mutt main menu mutt sets reverse video by default. You can change the way it displays things, however. On page 479 we’ll see howtochange it to the style shown in one shown in Figure 26-2. This display shows a number of things: • The line at the top specifies the name of the file (‘‘folder’’) that contains the mail messages (/var/mail/grog), the number of messages in the folder,and its size. It also states the manner in which the messages are sorted: first by threads,then by date. We’lllook at threads further down. • The bottom line givesabrief summary of the most common commands. Each command is a single character.You don’tneed to press Enter to execute the command. • The rest of the screen contains information about the messages in the folder.The first column givesthe message a number,then come some flags: • In the first column, we can see r next to some messages. This indicates that I have already replied to these messages. mua.mm,v v4.12 (2003/04/02 04:07:59) 473 Chapter 26: Electronic mail: clients 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 473 Figure26-2: mutt main menu • In the same column, N signalizes a new message (an unread message that has arrivedafter the last invocation of mutt finished). • The symbol D means that the message has been marked for deletion. It won’tbe deleted until you leave mutt or update the display with the $ command, and until then you can undelete it with the u command • The symbol + means that the message is addressed to me, and only to me. We’ll see belowhow mutt decides who I am. • The symbol T means that the message is addressed to me and other people. • The symbol C means that the message is addressed to other people, and that I have been copied. • The symbol F means that the message is from me. • The symbol * means that the message is tagged:certain operations work on all tagged messages. We’lllook at that on page 478. • The next column is the date (in international notation in this example, but it can be changed). • The next column is the name of the sender,or, ifI’m the sender,the name of the recipient. • The next column is the name of the recipient. This is often me, of course, but frequently enough it’sthe name of a mailing list. You’ll notice that this is a column I have added; it’snot in the default display. • The next column givesthe size of the message. The format is variable: you can specify number of lines (as in the example), or the size in kilobytes. mua.mm,v v4.12 (2003/04/02 04:07:59) Files,folders or directories? 474 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 474 • The last column is usually the subject. Formessages 56 to 61, it’saseries of line drawings. This is threading,and it shows a relationship between a collection of messages on the same topic. Message 56 was the original message in the thread, message 57 is a reply to message 56, and so on. Messages 60 and 61 are both replies to message 59. mutt automatically collects all messages in a thread in one place. You’ll notice in the example that the lines are of different intensity.Inthe original, these are different colours, and they’re a matter of personal choice; theyhighlight specific kinds of message. Iuse different colours to highlight messages on different topics. If you’re interested in the exact colours, see http://ezine.daemonnews.org/200210/ports.html, which contains an early version of this text. Message 52 is appears to be in reverse video. In fact, it’sinwhite on a blue background, acolour I don’tuse for anything else. This is the cursor,which you can position either with the cursor up and cursor down keys, or with the vi-likecommands j (move down) or k (move up). In the default display,itisinnormal video (i.e. not reversed, or doubly reversed). You can also move between pages with the left and right cursor commands. Manycommands, such as r (reply) or Enter (read), operate on the message on which the cursor is currently positioned. Forexample, if you press Enter at this point, you’ll see a display likethat in Figure 26-3. Figure26-3: mutt message display Here, the display has changed to showthe contents of the message. The top line now tells you the sender of the message, the subject, and howmuch of the message is displayed, in this case 50%. As before, the bottom line tells you the most common commands you might need in this context: they’re not all the same as in the menu display. The message itself is divided into three parts: the first 6 lines are a selection of the headers.The headers can be quite long. Theyinclude information on howthe message got here, when it was sent, who sent it, who it was sent to, and much more. We’lllook at them in more detail on page 482. The headers are separated from the message body by an empty line. The first part, which mua.mm,v v4.12 (2003/04/02 04:07:59) 475 Chapter 26: Electronic mail: clients 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 475 mutt displays in bold,isquoted text: by putting a > character before each line, the sender has signalized that the text was written by another person, often the person to whom it is addressed: this message is a reply,and the text is what he is replying to. Normally there is an attribution above the text, but it’smissing in this example. We’ll see attributions belowinthe section on replying. If the message is longer than one screen, press SPACE to page down and - (hyphen) to page up. In general, a 25 line display is inadequate for reading mail. On an X display, choose as high a windowasyou can. Replying to a message To reply to a message, simply press r. mutt starts your favourite editor for you. How does it knowwhich one? If you set your EDITOR environment variable to the name of your editor,itstarts that editor; otherwise it starts vi.You can also specify it in the mutt configuration file, which we’ll look at below. In this case, we start emacsclient. emacsclient isn’treally an editor at all: it simply finds an Emacs process and latches on to it. This is much faster than starting a newinstance of Emacs:it’spractically instantaneous, whereas evenonfast modern machines, starting Emacs causes a brief delay.Toexit the client, you use the key combination c-x c-#. Before entering anytext, the editor screen looks likeFigure 26-4. You’ll notice that mutt automatically ‘‘quotes’’the text. The original text started with: >I think I now understand the problem here. Try the following patch >and tell me if it solves the problem: > >--- vinumio.c 2May 2002 08:43:44 -0000 1.52.2.6 >+++ vinumio.c 19 Sep 2002 05:10:27 -0000 Tried patch. System no longer reads ad0h/ad2h, but after the second ’vinum start’, the system shows 0 drives (’vinum ld’ lists nothing.) This message itself starts with quoted text, which indicates that it was written by somebody else. Normally there should be a line at the top stating who wrote it, but it’s missing here. The text from the submitter starts with Tried patch.When you reply, however, all this text is quoted again, so what you see on the screen is the display of Figure 26-4. Here you see that the first line attributes the text below. You’ll notice that this reply also includes a selection of headers for the outgoing message. This can be very convenient if you want to tailor your headers to the message you’re sending, or just to add other recipients. mua.mm,v v4.12 (2003/04/02 04:07:59) Replying to a message 476 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 476 Figure26-4: Replying to a message: initial state In this case, since it’sinreply to a technical question, I change the From: header to my FreeBSD.org address and copythe original mailing list. Ialso remove irrelevant text and add a reply,asshown in Figure 26-5. It wasn’tnecessary to reformat the original text, since it was relatively short. The quoting method makes lines grow, though, and manyMUAshav e difficulty with long lines, so it’sagood idea to reformat long paragraphs. See http://www.lemis.com/email.html for more details. In this example, I reply with the r (reply to sender) command. Icould also do a group reply with the g key, which would include all the original recipients, so it wouldn’tbe necessary to add the mailing list again. Next, I leave the editor with c-x c-# and return to the screen in Figure 26-6. Here I have another opportunity to change some of the headers before sending the message. You’ll note what seem to be a couple of additional headers in this display: PGP and Fcc:. In fact, they’re not headers at all. PGP states what parts of the message, if any, should be encrypted with pgp or gpg.Inthis case, Clear (the default) means not to encrypt anything. Fcc: is also not a header.Itspecifies the name of a folder in which to save the outgoing message. We’ll look at folders in the next section. After making anyfurther changes to the headers, I send the message with the y command, after which I return to the previous display. mua.mm,v v4.12 (2003/04/02 04:07:59) 477 Chapter 26: Electronic mail: clients 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 477 Figure26-5: Replying to a message: after editing Figure26-6: Replying to a message: ready to send mua.mm,v v4.12 (2003/04/02 04:07:59) Replying to a message 478 2April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 478 Using folders As I mentioned, mutt can handle multiple folders. By default, it starts with your incoming mail folder,sometimes called an inbox.OnBSD, it is a single file in /var/mail with the same name as your user ID. We saw that above atthe top of the indexscreen: mine is called /var/mail/grog. mutt stores other folders as single files in the directory ˜/Mail,inother words a subdirectory of your home directory.ManyMUAsuse 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.Inthe previous section, the Compose menu contained the pseudo-header Fcc: =jbozza.This refers to the file ˜/Mail/jbozza:the shorthand = refers 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. Youcan thus reply a message, saving a copyinthe 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. Youcan do this by entering d.The D flag appears on the left of the line, but nothing much else happens. The message doesn’tget deleted until you exit mutt,oruntil you enter $. When you save a message to a folder,itisautomatically deleted from the current folder. If you don’twant to do that, or if you have accidentally deleted a message, you can undelete it by entering u. Finished reading a thread? Youcan delete the entire thread by entering ˆD (Control-D). Ta g ging messages We’v e 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. Youselect the messages under the cursor by entering t.Inthe example above,messages 51 and 64 are tagged. Youcan reply to all tagged messages in one reply by pressing ;r.Inthis 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 them all with ;d. mua.mm,v v4.12 (2003/04/02 04:07:59)

Ngày đăng: 11/12/2013, 00:15

TỪ KHÓA LIÊN QUAN

w