Home|Cudeso|Linux|*NIX / BSD|Misc|
 

Fetchmail

Contents

1. Introduction

2. Useful resources

3. Getting the package

4. Configuration

5. CronJob / Daemonmode

1. Introduction

Fetchmail is a service that you can use to retrieve mail from external mailservers.

First of all, what is fetchmail? I quote http://www.tuxedo.org/~esr/fetchmail/
Fetchmail is a full-featured, robust, well-documented remote-mail retrieval and forwarding utility intended to be used over on-demand TCP/IP links (such as SLIP or PPP connections). It supports every remote-mail protocol now in use on the Internet: POP2, POP3, RPOP, APOP, KPOP, all flavors of IMAP, ETRN, and ODMR. It can even support IPv6 and IPSEC.

Fetchmail retrieves mail from remote mail servers and forwards it via SMTP, so it can then be be read by normal mail user agents such as mutt, elm(1) or BSD Mail. It allows all your system MTA's filtering, forwarding, and aliasing facilities to work just as they would on normal mail.

2. Useful resources

The homepage of fetchmail http://www.tuxedo.org/~esr/fetchmail/

3. Getting the package

You can download the latest version from http://www.tuxedo.org/~esr/fetchmail/

When you're using Red-Hat it would be wise to download the rpm and install it.
rpm -Uvh fetchmail.rpm

4. Configuration

For a simple use, fetchmail is quite easy to configure. I'll only be covering the situation where I want to retrieve the mail that's waiting in the POP3 mailbox of my ISP.

By default, fetchmail uses a config-file that can be found at ~username/.fetchmailrc. It is also possible to start fetchmail from the command-line. When started from the command-line, all options provided will override those in the config-file.

Here's an example of what is in my config-file.
poll pop.myisp.com proto pop3 user "johndoe" password "secret" is "johndoe@localdomain.com" here
With poll you provide the server that needs to be contacted.

Then, with proto you specify the protocol that needs to be used (in this case it's POP3).

The user and password are quite obvious and provide your account and password at the server.

With the last directives, I make sure that the collected mail is deliverd to a local-mailbox (otherwise it would be quite hard to read it huh?).

5. CronJob / Daemonmode

For an automatic pick-up of your mail, you could write your own script that calls fetchmail every hour and delivers the mail. But in stead of using the cron-daemon you can start fetchmail also in daemon mode. This is very easily done by this command :
fetchmail --daemon 3600 (3600 = interval)
Interval is a numeric argument that specifies the polling interval in seconds. There can only be one daemon process per user, fetchmail makes a per-user lockfile to guarantee this.

You can stop the daemon with
fetchmail --quit
Off course, whenever you reboot your machine, you need to restart the daemon. You can automate this process by adding a line to /etc/rc.local that starts the daemon.


That's all there is for my configuration. Please check out the homepage of fetchmail because there are some other nifty features that could come in handy.
Copyleft 2002-2007 - cudeso.bewebmaster@cudeso.betop