Back to main page

The Quick-N-Dirty Guide to Fetchmail

1.) DO YOU HAVE FETCHMAIL?


In a command shell type

which fetchmail

This should return the path to fetchmail, probably /usr/bin/fetchmail. (In FreeBSD probably /usr/local/bin/fetchmail). If it finds it, go to step 3. If it doesn't go to step 2.

2.) INSTALLING FETCHMAIL


Go to the QND software guide for information about getting and installing fetchmail. We'll wait. If it turns out that fetchmail is not included with your particular flavor of Linux then try their home page which has rpms and source code.

3.) Configuring Fetchmail


For this guide we will assume that you have a user account at isp.com. Your user name is john, your email address is john@isp.com. Your password at isp.com is 1234. Your account on the Linux machine is jmith. Isp.com's pop server is called pop.isp.com

Open your favorite text editor and create a new file, .fetchmailrc

poll pop.isp.com proto pop3 user john password 1234
user john with pass 1234 is jsmith here
mda "/usr/bin/procmail -d %T"
Note:
This leaves your password in clear text. If you are on a box that has someone else as administrator, they will be able to read your password. The way around this is to leave out the password portion. Then the first two lines would read
poll pop.isp.com proto pop3 user john
user john is jsmith here

If done this way, you will have to enter your password each time you invoke fetchmail.

While configuring procmail is beyond the scope of this QND guide, the last line simply makes sure that if no other MDA is running, that procmail will handle delivery of the mail. (Although one should make sure that they have it--imitate Step 1 above with a

which procmail

If the path is not usr/bin--in FreeBSD it will probably be /usr/local/bin--adjust your .fetchmailrc accordingly.)

4) Test fetchmail


Simply type

fetchmail

You should see something like

5 messages for john at pop.isp.com (5855 octets).
reading message john@isp.com:1 of 5 (1688) octets

and more in the same vein.

If you are not using sendmail, postfix or another major MDA you may also see error messages like

SMTP connect to localhost failed fetchmail: can't raise the listener; falling back to /usr/bin/procmail -d %T flushed

It may also poll the pop server a second time and say that authorization failed. As long as you are getting the "flushed" part after each message, these error messages can be ignored.

Once the message is received, you can read it with whatever MUA (Mail User Agent) that you like, such as mutt.

Congratulations, you should be done. If you prefer to have fetchmail running constantly in the background, you can do so by typing

fetchmail -d 600

The 600 refers to seconds--this would poll isp.com every 10 minutes--you can adjust that number as desired. You could also add the line to your .bash_profile, .profile or .bashrc (depending upon O/S and distribution) so that fetchmail starts running as daemon each time you log into the machine.

References


man fetchmail
Fetchmail home page

Back to main page