Fetchmail

Fetchmail

Fetchmail is one of those handy tools that makes using an operating system like Linux so much fun. It's easy to configure, has lots of functionality, and does what you want, when you want, and without much complaining. You can run it from cron or run it by executing it from the command line. If life could only be so easy.

For the e-mail console, you will use Fetchmail to retrieve e-mail from your ISP. This means that you will have to switch your current e-mail client from using POP/IMAP to picking up e-mail locally. Why do you have to do this? Well, when the MDA on your system wants to send e-mail to your account, it will first check to see if a file named .forward is in your home folder. If it is, then all your mail will be forwarded to the e-mail address in the .forward file. But wait! We don't want that to happen. What we want is for the e-mail to be sent to Procmail for processing. You'll learn how to do this in the next section. For now, just remember that the .forward file is the key.

Fetchmail Configuration

Configuring Fetchmail is a breeze . All you need to do is create a .fetchmailrc file in your home folder. You can read the man page for Fetchmail and write this file yourself, or you can use fetchmailconf and generate the .fetchmailrc file. I wrote my original configuration file by hand, but the fetchmailconf application is a much faster way to get things going.

Figure 7-1 shows a screenshot where I'm adding a new remote e-mail server. Figure 7-2 presents a screenshot where I'm setting up the server protocol and adding a new e-mail account. Finally, Figure 7-3 shows a screenshot where I'm configuring the e-mail account password and setting up the processing options.

Figure 7-1. Fetchmail configuration ”new e-mail server.

Figure 7-2. Fetchmail configuration ”protocol setup.

Figure 7-3. Fetchmail configuration ”account setup.

Once fetchmail is configured and working, you will be able to run it from the command line or via cron. The screenshot in Figure 7-4 shows that Fetchmail got a single e-mail from my ISP and then flushed (removed) it from my ISP. When you want to automate the Fetchmail process, use cron to schedule a Fetchmail call, and make sure you use the silent (-s) command line parameter or else you'll be getting lots of messages from cron each time Fetchmail is run.

Figure 7-4. Fetchmail being executed.

crontab

In order to make the e-mail console work, you must run Fetchmail at regular intervals. Cron is usually a good way to go about doing this. Here's a sample crontab entry:

0,15,30,45 * * * * /usr/bin/fetchmail

 



Multitool Linux. Practical Uses for Open Source Software
Multitool Linux: Practical Uses for Open Source Software
ISBN: 0201734206
EAN: 2147483647
Year: 2002
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net