Although the Web drives the Internet economy, emailing remains the Internet's most-used function. It is therefore important that email be fully manageable from the Linux consoleand it is. The Pine program provides console users with powerful email management capabilities. To use Pine at the console, however, most users need to configure Linux to retrieve mail from a remote mail server. Fetching Post Office Protocol 3 or Internet Message Access Protocol MailFor most people who use a dial-up ISP and many who don't, managing email at the console begins with the process of bringing mail across from a Simple Mail Transfer Protocol (SMTP) capable mail server (used by most Internet service providers) to the local workstation where their mail is saved. Two major protocol families exist for transferring mail from an SMTP host to a local host: IMAP (Internet Message Access Protocol) and POP3 (Post Office Protocol). The Linux program best used to fetch mail from either kind of server is called fetchmail and is installed by Fedora Core 4 in all basic configurations. To use fetchmail, you create a configuration file called ~/.fetchmailrc (a file called .fetchmailrc stored in your home directory) that instructs fetchmail where to find your mail and how to go about getting it. After you create this configuration file, you call fetchmail from the command line to download all your mail from your mail server to the local host (your computer), where you can use a console-based mail program to access it. The following sections walk you through each of these processes. Creating the .fetchmailrc FileThe .fetchmailrc file is a plaintext file, and you can create it using either vi or emacs with methods you've already learned. The format of the file when used merely for downloading mail is relatively simple. You enter one line into the file for each mail server you want to download mail from. The format of this line is as follows: poll server protocol protocol username username password password Change the values for server, protocol, username, and password to the Internet address (domain name) of your mail server, the protocol (usually auto to automatically detect either POP3 or IMAP), your login, and your password, respectively. This information must be obtained from your network administrator, Internet service provider, hosting company, or web-based email provider, depending on which you use.
For example, consider the following entry from a .fetchmailrc file: poll mail.mycompany.com protocol auto username jackhenry password 3cheesesI8 This line causes fetchmail to download mail from a server located at mail.mycompany.com; fetchmail attempts to automatically detect the protocol that should be used. In this example, fetchmail attempts to log in to the mail server as jackhenry using the password 3cheesesI8. If you have only one mail server account, you need only one line in your .fetchmailrc file; more lines should be added depending on the number of servers you will be downloading mail from.
After you create a .fetchmailrc file, you must remove from it all permissions for group owner and for other users; otherwise, fetchmail will refuse to use the file. More importantly, if you don't protect your .fetchmailrc file by changing its permissions, your password will be vulnerable to theft. To make this change, use the chmod command and remove read, write, and execute permissions from group and other users (leaving them only for the owning user): [you@workstation20 ~]$ chmod og-rwx .fetchmailrc [you@workstation20 ~]$ ls -l .fetchmailrc -rwx------ 1 you you 259 Oct 23 2004 .fetchmailrc [you@workstation20 ~]$ Now you can test your new fetchmail configuration simply by entering the fetchmail command alone: [you@workstation20 ~]$ fetchmail 2 messages for jackhenry at mail.mycompany.com (1889 octets). reading message 1 of 2 (933 octets) flushed reading message 2 of 2 (956 octets) flushed [you@workstation20 ~]$ In this case, two messages are waiting to be downloaded from the mail server. They have now been downloaded and are stored on the local system where console-based mail clients can get to them. Each time you want to check the mail server for new mail, enter the command fetchmail. In Chapter 28, "Command-Line System Administration," you learn how to use the cron system to automate tasks of this kind so that fetchmail can be called regularly in the background. Using Pine to Manage Email from the ConsoleOne of the most widely used console-based email programsand perhaps the most user-friendlyis Pine, based on a classic interactive mailer called Elm. Pine provides the user with a wealth of powerful email features, including support for filters, address books, and MIME attachments. Although there are several ways to read and reply to email at the command line, we focus on Pine here because it is menu driven and familiar to many Unix users. Downloading and Installing PineBecause Pine is not included by default with Fedora Core 4, you need to download the Pine application from Red Hat and install it yourself. Follow these steps exactly to do so:
You should now have Pine 4.62 installed and available to you on your Fedora Core 4 system. The two commands used here need a little bit of explaining:
Starting PineTo start Pine after you have installed it, type pine at the the command line. The first time you run Pine, you are greeted by the Pine welcome screen (titled Greeting Text), which contains some information about the program, as shown in Figure 23.5. Figure 23.5. The Pine welcome screen is displayed the first time you start Pine.Notice that a number of keys and their meanings are listed at the bottom of the display. While you are working inside Pine, the most common keystrokes used at a given screen are always displayed at the bottom for your convenience. Pressing Enter at the Pine welcome screen sends an email to the Pine maintainers notifying them that another Pine user has gone online. You are then taken to the Pine Main Menu, which you will see whenever you start Pine, as shown in Figure 23.6. Figure 23.6. The Pine Main Menu is easy to navigate; the number of messages in your INBOX is displayed at the bottom of the screen.You can navigate the Pine Main Menu by using the keystrokes listed at the bottom of the display, or by pressing the arrow keys to select an item from the menu and Enter to select the item you want to activate. Setting Pine PreferencesBefore using Pine for sending and receiving mail, you should take a moment to configure Pine's behavior with regard to message sorting, reply quoting, and so on. To enter Pine setup from the Main Menu, either press the s key, or use the arrow keys to navigate to the Setup option and then press Enter. The general Setup screen is shown in Figure 23.7. Figure 23.7. The general Setup screen for Pine holds commands for setting printing, password, configuration, and signature preferences.New Pine users need only focus on the options in the Configuration area. You can enter this area by pressing the c key at the Setup screen. The Setup Configuration area appears, as shown in Figure 23.8. Figure 23.8. The Pine Setup Configuration area contains a ponderous number of configuration options. You should leave most of them alone.To change individual configuration options, use the up- and down-arrow keys to select an option you want to change and then press Enter to select or unselect that option. Watch the lines at the bottom of the screen carefully; it is in this area that you are prompted for input when necessary. You change one option in this chapter; leave the rest of them alone for now. Specifying a From Address in PineOne option in Pine is important for users of the POP or IMAP family of protocols. Because your email address is typically not hosted on your local workstation, but rather on a mail server at a separate host, you need to explicitly tell Pine to use an email address other than the default (which is constructed using your login name and your workstation's hostname). To specify your email address, use your arrow keys to scroll nearly all the way to the bottom of the Setup Configuration area to the option called customized-hdrs and select it by pressing Enter. At the prompt, enter a complete From: header in the following form: From: My Name <myaddr@myserver.com> For example, if your name is Jack Henry and your email address is jackhenry@mycompany.com, you enter the following in the customized-hdrs option: From: Jack Henry <jackhenry@mycompany.com> After you exit setup, saving your changes, Pine uses this address as the default From address for email until it is changed. Composing Mail Using PineTo compose a new message from Pine's Main Menu, press the c key, or use the arrow keys to navigate to Compose Message and then press Enter (refer to Figure 23.6). You can also press c in the Message Index or Text screens discussed in the following sections to compose a new message. A new Compose Message screen is displayed, as shown in Figure 23.9. Figure 23.9. Use the up- and down-arrow keys to navigate between the address and subject fields at the top of the Pine Compose Message screen.At the top of the Compose Message screen are four fields: To:, Cc:, Attchmnt:, and Subject:. Fill in each field, using the up- and down-arrow keys to switch between them. If you would like to supply multiple recipients in the To: or Cc: fields, separate their email addresses with a comma. After you finish filling the fields, press the down arrow repeatedly to move the cursor into the message editor area of the screen.
You are now in the pico editor, a subcomponent of Pine that works like a simple text editor. Notice that pico automatically word-wraps your text and supports user-friendly arrow-key movement and editing keys, such as Backspace and Delete. Also, notice that several editing keystrokes are listed along the bottom of the screen; the caret (^) means that you invoke the keystroke by holding down the Ctrl key and pressing the letter indicated (refer to Figure 23.9). After you finish editing a message and are ready to send it, use the ^X keystroke (Ctrl+X) to actually send the message out across the network. To cancel a message, use the ^C (Ctrl+C) keystroke. Reading Mail Using PineTo use Pine to read mail from your default mailbox (the one fetchmail services), select the Folder List screen at the Main Menu by pressing l, or by scrolling down to the Folder List option and pressing Enter. Then select INBOX and press Enter again. The Message Index screen then appears, as shown in Figure 23.10. Figure 23.10. The Pine Message Index screen lists messages contained in the default INBOX folder, and it displays a list of keystroke commands you can use in this screen.You can navigate within this list of messages using the arrow keys to select individual messages and the Enter key to display them. Other available keys are shown at the bottom of the display (refer to Figure 23.10). Pressing the o key shows still more available keystrokes. Messages marked with the letter N on the far left are messages that you haven't yet viewed. After a message is displayed, as shown in Figure 23.11, you have a number of choices for dealing with the message. The most common keystrokes used at the Message Text screen are shown in Table 23.4. Figure 23.11. The Pine message viewer, the Message Text screen, is quite user-friendly.
Other keystrokes are listed at the bottom of the Message Text screen; you can find still more keystrokes by repeatedly pressing the o key. Getting Help and Quitting PineYou can access a nice online Pine manual by returning to the Main Menu (use the m key from anywhere but inside the Compose Message screen) and pressing the ? key. Alternatively, you can select the Help menu option at the Main Menu and press Enter. When you are ready to exit Pine, press the q key from either the Main Menu, the Message Index screen, or the Message Text screen. Pine prompts you to confirm that you want to exit and then returns you to the command line after purging all messages marked for deletion.
|