fetchmail - the mailman
List | Home
LinuxNetMag #2

QuakeII: XQF, MODs
Action: Maelstrom, bzflag


suck news
ISDN answering machine
recommended links


Zip Drive
SANE - scanning

Editorial Office

List of articles


  Mailbox You have more than one mail account or different users are working on one PC and all of them want to use e-mail?
Or you want to supply your Local Area Net with mail from the internet?
Fetchmail does all this do automatically!
The usual WINDOWS user reads and writes his mail with Netscape or IE and also uses these programs to download his mail from the internet. Using Linux you are able to do it the same way, but Linux is a multi-user system and this mail solution does not  make sense any longer with two ore more users who want their mail.
One for all

With fetchmail downloading is automated. Fetchmail is able to administrate the mail for all users, and with somemore configuration options for the whole LAN. Or if you have more than one mail account fetchmail is useful, too. Usually fetchmail is included in many Linux distributions otherwise you have to install it now (with S.u.S.E. install the package fetchmail.rpm in the net folder). After installing the package the configuration file has to be configured. The root user creates the file .fetchmailrc if it did not exist.

>> touch .fetchmailrc
And this file has to be fitted as follows:
File /root/.fetchmailrc
# poll POPSERVER protocol POP3 
#First Account
poll protocol POP3 user mymailname to mylocalername password mypasswort
# Second Account
poll protocol POP3 user mymailname2 to mylocalername  password mypasswort2

In this file you include for every user the address where he stores his mail and to whom the mail has to be forwarded on the local computer.
For every account the configuration text has to be placed in one line. The line starts with poll followed by the server name where the mail is stored. Then you specify the protocol. Usually the internet servers are POP3 servers. With user you specify the name of the POP3 server. This is the part of the e-mail address before the "@". Last but not least the program has to know who of the local users should receive the mail. To achive this you enter the name behind the to with witch the user logs in. Of course you need the password for the internet server to get the mail from the POP3 server.

In the configuration file the passwords are not encoded. This file must not be readable for normal user just for root. If you forgot this fetchmail would remind you at once.

>> chmod og-xrw ~/.fetchmailrc
you change the file to a secure one.
If you keep your mail on more than one POP3 server there is no problem to get the mail from there with an additional entry and to forward them to the same local user. For additional users on the local system you add another entry into the file .fetchmailrc .
The downloaded mail is saved in the directory /var/spool/mail/ . Every user has his own file there where all of his mail is collected. Now you are able to read your mail with any mail reader. You have to configure the localhost or of the POP3 mail server in your mail program. Then, you can download the mail from your localhost instead of from the internet and you do not need a telephone connection to the internet.
Why work? Use a deamon!

How to start the program for downloading the mail?
As the first try you should connect normally to the internet and start the program on your own with 

>> fetchmail -a
This command download the mail from the internet server and deletes the mail there. They are saved at the local POP3 server.
If problems occurred you should add the options -v to get verbose information about the connection and to find the error faster.
As soon as fetchmail works all right you are able to start the program as a deamon in the background. This is achieved with the command
>> fetchmail -d 300
The number stands for a time interval in seconds. After that many seconds fetchmail looks for new mail. This feature does not make sense if you are offline. To activate the deamon if you are online write this command in the file /etc/ppp/ip-up . Additional to the other commands you should add 
fetchmail -quit
fetchmail -d 300
The first command terminates a possibly running fetchmail and restarts fetchmail with the started interval. After disconnecting fetchmail should be stopped. Just add in /etc/ppp/ip-down the line "fetchmail -quit". This way fetchmail would start automatically if you connected and would stop if you disconnected to the internet. Now you have an automatically mail transportation system.

How you can serve the whole local net with fetchmail will be explained in the next issue of LinuxNetMag.

Other issues of Linux NetMag
[ #1 | #2 | #3 | Main ]