Creating a Complete Configuration File

The preceding description of Fetchmail options may seem quite abstract. To help clarify the matter, Listing 25.3 presents a sample .fetchmailrc file. This file begins by setting a few global options: the Fetchmail postmaster account, the option to send bounces to the original sender, the option to use the system logger, and the option to run in daemon mode with a poll interval of 1,800 seconds (30 minutes). The file continues with two source definitions: mail.asmallisp.net and pop.abigisp.net. Mail from the example account on mail.asmallisp.net is retrieved using IMAP and delivered to the local user ben. This account is polled only once every four intervals—that is, four times the 30-minute daemon interval, or once every two hours. Mail from the samplemail account on pop.abigisp.net is retrieved using POP3 and delivered to the user sally on mail.example.com, which might or might not be the same computer on which Fetchmail runs.

Listing 25.3: Sample Fetchmail Configuration File set postmaster "ben" set bouncemail set syslog set daemon 1800

poll mail.asmallisp.net with proto IMAP

user "example" there with password "p3iYAoQB" is ben here options fetchall forcecr interval 4

poll pop.abigisp.net with proto POP3

user "samplemail" there with password "l*uy9|bBj" is sally here options fetchall forcecr smtphost mail.example.com

Chances are that a file similar to Listing 25.3 will suit your needs, although of course you must modify various features, such as mail server names, usernames, and passwords. Save the configuration file in an ordinary user account and give it 0710 (-rwx-x—) or more restrictive permissions; in order to discourage you from storing your mail password in a file that's readable to anybody but you and root, Fetchmail refuses to run if anybody but the file's owner can read the configuration file.

Warning Because Fetchmail requires your mail password to be stored in the clear in a file in your account, this file is extremely sensitive. Don't make a backup of the file that can be read by anybody else. If possible, use your mail passwords only for your mail account, not for any other purpose.

If you prefer to use GUI configuration tools, you may want to look into fetchmailconf, which is a GUI tool for generating Fetchmail configuration files. When you launch the program, it gives you options to configure Fetchmail, test Fetchmail, or run Fetchmail. If you opt to configure the program and then pick expert mode, it displays a dialog box similar to the one shown in Figure 25.4. You set global options in the area entitled Fetchmail Run Controls. Type a pull mail server's hostname in the New Server field and press the Enter key to bring up a large dialog box in which you enter the information that will appear on a single poll line.

[¿3 Click To expand

Figure 25.4: People who like GUI configuration tools can configure Fetchmail with one.

When you believe you have a configuration that should work, you can test it. For testing purposes, I recommend commenting out any daemon line you may have entered. As the user who created the configuration, type fetchmail -k to retrieve messages while leaving the originals on the mail server. If all goes well, Fetchmail should respond by displaying a series of dots (.), indicating its progress in retrieving messages. Your messages should then appear in your local mail queue. Try using a local mail reader to see if the messages are available.

Tip The account used to run Fetchmail is unimportant, except insofar as the account owner must be the only ordinary user with read privileges on the Fetchmail configuration file. For instance, the user ben may run Fetchmail, which then delivers local mail to ben, sally, and other users. Running Fetchmail asroot is definitely not necessary, and in fact is a potential security risk. In theory, a bug in Fetchmail could enable a miscreant to write a mail message that would cause Fetchmail to misbehave and do things with root privileges that you don't want done.

0 0

Post a comment