next up previous
Next: Sendmail Up: Mail Handling Previous: QPopper

Subsections

Fetchmail

By now you have already downloaded the fetchmail source code, as described in section A.2. You can unpack this code by using the command zcat fetchmail.version.tar.gz | tar xvf -

Making and Installing Fetchmail

Make sure that you are using the /usr/ccs/bin/make version of make. Fetchmail comes with a configuration script. To set up the makefile, use ./configure Once you have configured fetchmail, you will need to modify the Makefile to include the resolv library. Modify the LOADLIBS line, so that it looks like: LOADLIBS = -lresolv -lsocket -lnsl -lfl

If you want to install fetchmail into a directory other than /usr/local/{bin,lib,man} then you will need to modify the prefix and bindir etc. entries in the Makefile.

To make fetchmail, just use make to make the program and make install to install it.

Configuring Fetchmail

Fetchmail can be run by anyone. Each user can have a separate .fetchmailrc file in their home directory, which they can use to get mail on demand.

For the purposes of this document, I am going to assume that fetchmail will be run by a central user -- root -- which gets mail from whatever mailboxes are needed and forwards the results to various users. This approach rather assumes that you are running a small network where there is a single user (you) in various guises, or a few users who trust each other.

The .fetcmailrc File

The root user needs to have a /.fetchmailrc file configured so that fetchmail knows where to get mail and what POP3 accounts to get it from. A sample .fetchmailrc file is shown in figure 18. This file tells fetchmail to contact the ISP's mail server and check for mail first for a user called doug and then for a user called alison. Mail sent to the user doug@orac.net.au is delivered to the local user douglas. Mail sent to the user alison@orac.net.au is delivered to the local user called alison.

Figure 18: Sample .fetchmailrc File


#
#       Sample .fetcmailrc file
#
poll pop.nat.orac.net.au
        with protocol pop3
        username doug password PPPPPPPP is douglas
        username alison password XXXXXXXX is alison
;


 

Note that the /.fetchmailrc file has passwords in plain text in it. This file should be set to mode 600 to avoid snooping eyes.

It is possible to configure fetchmail to get messages from a single ISP mailbox and distribute the results to several local mailboxes, a process known as multidrop. The fetchmail man pages contain a description of how to do this.

Crontab Entries

Fetchmail essentially polls your ISP's POP3 server to see if there is anything worth downloading. In theory, you can run fetchmail as a daemon and have it regularly poll for incoming mail. However, with the sort of dial on demand PPP interface we have here, fetchmail will always be bringing the link up to see if there is anything there. Fetchmail can stop itself from polling on inactive links, but only on Linux systems.

The simplest solution is to simply set up cron entries to check for mail at regular points. Sample crontab entries are:



0 8,10,12,14,18 * * 1-5 /usr/local/bin/fetchmail -s
0 0,5,17 * * * /usr/local/bin/fetchmail -s


These entries start fetchmail in silent mode at 12am,5am,8am,10am,12pm,2pm,5pm and 6pm on weekdays and 12am,5am and 5pm on weekends.

Testing Fetchmail

Fetchmail is fairly easy to test. Once you have set up your .fetchmailrc file, using /usr/local/bin/fetchmail -v will give you a verbose trace of its operations.


next up previous
Next: Sendmail Up: Mail Handling Previous: QPopper
Doug Palmer 2003-02-15