|< Day Day Up >|
Depending on how your machine is configured, you might not have a use for the basic email reading command discussed in this chapter, mail. It is detailed here partly for historical completeness, and partly because it is an excellent utility for your use, if you have the opportunity.
The mail program is an email reading and sending program that works on email that is actually received and managed by your local machine. If all you've ever used is a POPmail or IMAP client, such as Eudora or Mailsmith, you're probably unfamiliar with the idea of your local machine being its own email server. Unix machines have, since the dawn of email, been part of the backbone by which email makes its way around the Internet. Configured properly, they don't need POPmail servers they are POPmail (and IMAP) servers. Email gets around between them by way of the SMTP (Simple Mail Transfer Protocol) and is delivered (with a few minor exceptions) directly from the sender's machine to the receiver's machine.
What does this mean to you? If your machine is set up to receive and deliver mail itself, mail doesn't arrive at 10-minute intervals (or however frequently you have your POPmail client configured to connect). It arrives as instantaneously as it can make its way across the Internet usually within a few seconds of being sent. It doesn't require your ISP's mail service to be up and running for you to receive mail because you (for email purposes) are your own ISP. Old-time Unix users are frequently amused by the instant messaging services that seem to be all the rage as the hot new Internet technology. Unfettered by the POPmail and IMAP protocols, plain old email is an instant messaging technology.
In this section we will look at fetchmail, mail, and pine.
Retrieving Remote Mail: fetchmail
As the name suggests, the fetchmail command fetches your mail for you. Specifically, it retrieves your mail from a remote server and sends it to your local mail server, where you can use email reading clients such as mail or pine.
If you are running your own mail server, fetchmail provides an easy way to store all of your mail in one place. Even if you prefer to read mail from your various email accounts using different packages or via webmail interfaces, you might still want to use fetchmail to retrieve all of your mail to archive it in one place.
The fetchmail utility is controlled by a control file, ~/.fetchmailrc, and command-line arguments. The command-line arguments override the control file.
Before you have fetchmail retrieve all of your mail, you can test whatever settings you are considering with the -V flag first. Here is a sample of what you might see during such a trial run:
ryoohki:~ joray$ fetchmail -V -v -k -u ray.3 pop.service.ohio-state.edu This is fetchmail release 6.2.5+SSL+INET6 Fallback MDA: (none) Darwin ryoohki.biosci.ohio-state.edu 8.0.0b2 Darwin Kernel Version 8.0.0b2: Wed Dec 1 23 :33:09 PST 2004; root:xnu/xnu-708.1.obj~1/RELEASE_PPC Power Macintosh powerpc Taking options from command line Idfile is /Users/joray/.fetchids Fetchmail will show progress dots even in logfiles. Fetchmail will forward misaddressed multidrop messages to joray. Fetchmail will direct error mail to the sender. Options for retrieving from firstname.lastname@example.org: Mail will be retrieved via pop.service.ohio-state.edu True name of server is pop.service.ohio-state.edu. This host will be queried when no host is specified. Password will be prompted for. Protocol is auto (using default port). All available authentication methods will be tried. Server nonresponse timeout is 300 seconds (default). Default mailbox selected. Only new messages will be retrieved (--all off). Fetched messages will be kept on the server (--keep on). Old messages will not be flushed before message retrieval (--flush off). Rewrite of server-local addresses is enabled (--norewrite off). Carriage-return stripping is disabled (stripcr off). Carriage-return forcing is disabled (forcecr off). Interpretation of Content-Transfer-Encoding is enabled (pass8bits off). MIME decoding is disabled (mimedecode off). Idle after poll is disabled (idle off). Nonempty Status lines will be kept (dropstatus off) Delivered-To lines will be kept (dropdelivered off) No received-message limit (--fetchlimit 0). Fetch message size limit is 100 (--fetchsizelimit 100). Do binary search of UIDs during 9 out of 10 polls (--fastuidl 10). No SMTP message batch limit (--batchlimit 0). No forced expunges (--expunge 0). Messages will be SMTP-forwarded to: localhost (default) Spam-blocking disabled No pre-connection command. No post-connection command. Single-drop mode: 1 local name(s) recognized. joray No plugin command specified. No plugout command specified. No poll trace information will be added to the Received header. . You have new mail in /var/mail/joray
You can have fetchmail retrieve all of your mail and keep it on the remote server, or delete messages after it has retrieved them, and much more. Table 13.8 contains select command documentation for fetchmail.
Here is some sample output showing what you might expect when fetchmail is actually fetching mail. The -v flag, the verbose flag, has been turned on. In this example fetchmail retrieves mail, but leaves messages on the remote server. If I weren't expecting to erase and install various incarnations of Tiger on this machine, I would have fetchmail delete messages after retrieval.
ryoohki:~ joray$ fetchmail -v -k -u ray.3 pop.service.ohio-state.edu Enter password for email@example.com: fetchmail: 6.2.5 querying pop.service.ohio-state.edu (protocol auto) at Tue, 04 Jan 2005 09:52:04 -0500 (EST): poll started fetchmail: 6.2.5 querying pop.service.ohio-state.edu (protocol IMAP) at Tue, 04 Jan 2005 09:52:04 -0500 (EST): poll started fetchmail: IMAP< * OK IMAP4 Ready mail-proxy3 00020153 fetchmail: IMAP> A0001 CAPABILITY fetchmail: IMAP< * CAPABILITY IMAP4 IMAP4REV1 STARTTLS LOGINDISABLED fetchmail: IMAP< A0001 OK CAPABILITY fetchmail: IMAP> A0002 STARTTLS fetchmail: IMAP< A0002 OK Begin TLS negotiation now fetchmail: Issuer Organization: The Ohio State University fetchmail: Issuer CommonName: mail-proxy1.service.ohio-state.edu fetchmail: Server CommonName: mail-proxy1.service.ohio-state.edu fetchmail: Server CommonName mismatch: mail-proxy1.service.ohio-state.edu != pop.service .ohio-state.edu fetchmail: pop.service.ohio-state.edu key fingerprint: F9:29:29:82:CC:B9:89:FE:F8:60:D6:F0 :3D:6B:D4:DF fetchmail: Warning: server certificate verification: self signed certificate . . . fetchmail: IMAP> A0003 CAPABILITY fetchmail: IMAP< * CAPABILITY IMAP4 IMAP4REV1 fetchmail: IMAP< A0003 OK CAPABILITY fetchmail: IMAP> A0004 LOGIN "ray.3" * fetchmail: IMAP< A0004 OK You are so in fetchmail: IMAP> A0005 SELECT "INBOX" . . . fetchmail: IMAP< ) fetchmail: IMAP< A0636 OK Completed fetchmail: SMTP>. (EOM) fetchmail: SMTP< 250 Ok: queued as ADB2992864 not flushed fetchmail: IMAP> A0637 STORE 633 +FLAGS (\Seen) fetchmail: IMAP< * 633 FETCH (FLAGS (\Seen)) fetchmail: IMAP< A0637 OK Completed fetchmail: IMAP> A0638 LOGOUT fetchmail: IMAP< * BYE LOGOUT received fetchmail: IMAP< A0638 OK Completed fetchmail: 6.2.5 querying pop.service.ohio-state.edu (protocol IMAP) at Tue, 04 Jan 2005 10:01:54 -0500 (EST): poll completed fetchmail: 6.2.5 querying pop.service.ohio-state.edu (protocol auto) at Tue, 04 Jan 2005 10:01:54 -0500 (EST): poll completed fetchmail: SMTP> QUIT fetchmail: SMTP< 221 Bye fetchmail: normal termination, status 0 You have new mail in /var/mail/joray
Building Block Simplicity: mail
The mail program is a simple command-line program for sending and reading email. Invoked with no arguments, its default behavior is to display the list of messages in your system mailbox and provide a prompt from which further interaction can occur. Used in this fashion, mail produces output similar to the code following the note.
ryoohki:~ joray$ mail Mail version 8.1 6/6/93. Type ? for help. "/var/mail/joray": 209 messages 209 unread >U 1 firstname.lastname@example.org Tue Jan 4 09:57 146/7905 "CBSSTAFF mailing list" U 2 email@example.com Tue Jan 4 09:57 49/2105 "WHICH" U 3 firstname.lastname@example.org Tue Jan 4 09:57 85/3441 "CBSSTAFF: Warning dur" U 4 email@example.com Tue Jan 4 09:57 56/2500 "Subscription approval" U 5 firstname.lastname@example.org Tue Jan 4 09:57 5675/432904 "RE: windows ssh stu" U 6 email@example.com Tue Jan 4 09:57 181/7710 "New CERT Coordination" U 7 firstname.lastname@example.org Tue Jan 4 09:57 311/12778 "CERT Advisory CA-2003" U 8 OSUToday@osu.edu Tue Jan 4 09:57 187/8865 "Headlines for Wednesd" U 9 OSUToday@osu.edu Tue Jan 4 09:57 185/8613 "Headlines for Thursda" U 10 email@example.com Tue Jan 4 09:57 251/10400 "CERT Advisory CA-2003" U 11 OSUToday@osu.edu Tue Jan 4 09:57 185/9048 "Headlines for Friday," U 12 OSUToday@osu.edu Tue Jan 4 09:57 193/9549 "Headlines for Monday," U 13 firstname.lastname@example.org Tue Jan 4 09:57 131/4928 "Fwd: Wellness Tip" U 14 OSUToday@osu.edu Tue Jan 4 09:58 170/7975 "Headlines for Tuesday" U 15 OSUToday@osu.edu Tue Jan 4 09:58 176/8488 "Headlines for Wednesd" U 16 email@example.com Tue Jan 4 09:58 149/6610 "Error Condition Re: U" U 17 OSUToday@osu.edu Tue Jan 4 09:58 209/10204 "Headlines for Thursda" U 18 OSUToday@osu.edu Tue Jan 4 09:58 189/9044 "Headlines for Friday," U 19 OSUToday@osu.edu Tue Jan 4 09:58 186/8988 "Headlines for Monday," U 20 firstname.lastname@example.org Tue Jan 4 09:58 462/18690 "SGI Security Advisory" &
The & on the last line is the internal mail prompt from which you can enter commands. At the & prompt, you have a number of options. These include the expected functions of reading, sending, and deleting messages, as well as a few others. Table 13.9 details the syntax and some useful options in the mail program. In this example we are looking at the mail that was just retrieved via fetchmail. The mail utility displays the date as the download date in this summary view. If you actually look at a message, though, you can see the actual message date in the Date: line, as shown in the headers for message 8:
& 8 Message 8: From email@example.com Tue Jan 4 09:57:55 2005 X-Original-To: joray@localhost Delivered-To: firstname.lastname@example.org Date: Tue, 04 Nov 2003 22:01:43 -0500 (EST) Date-warning: Date header was inserted by mail-mta1.service.ohio-state.edu From: OSUToday <OSUToday@osu.edu> Subject: Headlines for Wednesday, Nov. 5, 2003 To: email@example.com MIME-version: 1.0 Content-type: TEXT/PLAIN Content-transfer-encoding: 8BIT X-BulkMail-Envelope-From: <firstname.lastname@example.org> Original-recipient: rfc822;email@example.com X-Status: X-Keywords: X-UID: 8
Full-Featured Power: pine
pine is a command-line-based modern email client. It provides access to system mailboxes as well as remote (or local if you choose) POPmail and IMAP servers. The pine email client provides an interface that will be much more familiar to users of applications such as Eudora. Although text-based, it provides a menu-driven interface with multiple mailboxes, sophisticated filtering, and other friendly conveniences. As of this writing, Apple doesn't distribute pine as a default application with Mac OS X, but it's a popular enough mail client that many sites will have it installed. If you're playing system administrator for your own machine, the installation of pine is covered in Chapter 14.
pine, being a menu-driven, windowed system, doesn't lend itself to command documentation tables, so we give you some output captures. The first output capture shows the first pine screen you'll see when you start it up. Unless you have postfix working properly, don't press the Return key to send the requested statistic information!
PINE 4.61 GREETING TEXT No Messages <<<This message will appear only once>>> Welcome to Pine ... a Program for Internet News and Email We hope you will explore Pine's many capabilities. From the Main Menu, select Setup/Config to see many of the options available to you. Also note that all screens have context-sensitive help text available. SPECIAL REQUEST: This software is made available world-wide as a public service of the University of Washington in Seattle. In order to justify continuing development, it is helpful to have an idea of how many people are using Pine. Are you willing to be counted as a Pine user? Pressing Return will send an anonymous (meaning, your real email address will not be revealed) message to the Pine development team at the University of Washington for purposes of tallying. Pine is a trademark of the University of Washington. [ALL of greeting text] ? Help E Exit this greeting - PrevPage % Print Ret [Be Counted!] Spc NextPage
As you can see, you can choose from any keys at the bottom to start using the program.
The following is the more typical pine top-level screen from which you'll work. You can choose items from the textual menu shown on the screen, and also choose commands from those shown at the bottom of the screen. One thing that you should be aware of is that pine usually expects you to "go back" to get out of any particular situation or location you've gotten to in the program. It's sort of like wandering around on the World Wide Web there isn't necessarily a link back to the first page from any subpages several layers down in the system. Look for options that take you to the previous screen and so on to assist in navigating the system.
PINE 4.61 MAIN MENU Folder: INBOX 209 Messages ? HELP - Get help using Pine C COMPOSE MESSAGE - Compose and send a message I MESSAGE INDEX - View messages in current folder L FOLDER LIST - Select a folder to view A ADDRESS BOOK - Update address book S SETUP - Configure Pine Options Q QUIT - Leave the Pine program Copyright 1989-2004. PINE is a trademark of the University of Washington. [Folder "INBOX" opened with 209 messages] ? Help P PrevCmd R RelNotes O OTHER CMDS > [ListFldrs] N NextCmd K KBLock
Here is what the mail we downloaded with fetchmail looks like as viewed in the pine email reader. Note that pine displays the actual message date rather than the download date. Again, at the bottom, is a menu that guides you through using the program.
PINE 4.61 MESSAGE INDEX Folder: INBOX Message 1 of 209 NEW N 1 Oct 10 Sandy Shew (7907) CBSSTAFF mailing list (and list of add N 2 Oct 13 OSU ListProcessor (2022) WHICH N 3 Oct 13 firstname.lastname@example.org (3396) CBSSTAFF: Warning during message deliv N 4 Oct 13 OSU ListProcessor (2424) Subscription approval request N 5 Oct 14 Sandy Shew (438K) RE: windows ssh stuff N 6 Oct 15 CERT Advisory (7764) New CERT Coordination Center (CERT/CC) N 7 Oct 16 CERT Advisory (13K) CERT Advisory CA-2003-27 Multiple Vuln N 8 Nov 4 OSUToday (8938) Headlines for Wednesday, Nov. 5, 2003 N 9 Nov 5 OSUToday (8684) Headlines for Thursday, Nov. 6, 2003 N 10 Nov 11 CERT Advisory (11K) CERT Advisory CA-2003-28 Buffer Overfl N 11 Nov 13 OSUToday (9118) Headlines for Friday, Nov. 14, 2003 N 12 Nov 16 OSUToday (9627) Headlines for Monday, Nov. 17, 2003 N 13 Nov 17 Cathy Drake (4944) Fwd: Wellness Tip N 14 Nov 17 OSUToday (8030) Headlines for Tuesday, Nov. 18, 2003 N 15 Nov 18 OSUToday (8549) Headlines for Wednesday, Nov. 19, 2003 N 16 Nov 19 email@example.com (6620) Error Condition Re: Undelivered Mail R N 17 Nov 20 OSUToday (10K) Headlines for Thursday, Nov. 20, 2003 N 18 Nov 20 OSUToday (9118) Headlines for Friday, Nov. 21, 2003 N 19 Nov 23 OSUToday (9059) Headlines for Monday, Nov. 24, 2003 ? Help < FldrList P PrevMsg - PrevPage D Delete R Reply O OTHER CMDS > [ViewMsg] N NextMsg Spc NextPage U Undelete F Forward
|< Day Day Up >|