fetchmail
(package
pop
, series n
).fetchml
, series n
; from
SuSE Linux 7.1 on: package fetchmail
)
The advantage of fetchmail
over the older popclient
is
that the password does not appear in the process table but is only exchanged
between the mail server and the POP3 client; the password itself is stored in
a separate file.
Let's say the mail server is mail.provider.com
. There are two users,
asterix
and obelix
, who are called eve
and mary
on the host. The passwords (on the mail server) are adam
and joseph
.
/root/.fetchmailrc
and enter the following:
poll mail.provider.com protocol POP3 user asterix password adam is eve poll mail.provider.com protocol POP3 user obelix password joseph is marySince this file contains the passwords, it should only be readable for the user who collects the mail, i.e.:
chmod 600 /root/.fetchmailrcThe passwords do not necessarily have to be stored in this file. However, in this case the password will be queried each time
fetchmail
is started.inetd
whenever necessary, since fetchmail
transfers the mail to the local host at port 25.procmail
to be started
directly (i.e. no local SMTP daemon is required) can be effected
with the following modification:
poll mail.provider.com protocol POP3 user asterix password adam mda "/usr/bin/procmail -d eve" poll mail.provider.com protocol POP3 user obelix password joseph mda "/usr/bin/procmail -d mary"
fetchmail -v --keep -a >> /var/log/fetchmail 2>&1The
--keep
option makes sure mail is not deleted immediately on the server.
We strongly recommend use of this option during the test phase!/var/log/fetchmail
:
the -v
parameter makes sure only the most important information is recorded.fetchmail -a >> /var/log/fetchmail 2>&1
crontab -e
) regularly retrieves mail once a
day at 0200 hours:
0 2 * * * /usr/bin/fetchmail -a >> /var/log/fetchmail 2>&1
fetchmail
as daemon, e.g. by means of the following init script:/usr/share/doc/packages/fetchmail/README.SuSE
)
#! /bin/sh # Copyright (c) 1996 SuSE GmbH Nuernberg, Germany. All rights reserved. # # Author: Klaus Franken # # /sbin/init.d/fetchmail # # please edit /root/.fetchmailrc . /etc/rc.config return=$rc_done case "$1" in start) echo -n "Starting fetchmail-daemon" /usr/bin/fetchmail -d 900 -a -f /root/.fetchmailrc -L /var/log/fetchmail 2>&1 || return=$rc_failed echo -e "$return" ;; stop) echo -n "Shutting down fetchmail-daemon" /usr/bin/fetchmail -quit || return=$rc_failed echo -e "$return" ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0For the option -f, you must indicate the path to the
.fetchmailrc
of the user who wants to collect the mail.
cd /sbin/init.d chmod +x fetchmail cd /sbin/init.d/rc2.d ln -s ../fetchmail S06fetchmail ln -s ../fetchmail K39fetchmailIf you work in runlevel 3 (graphical login), add the following:
cd /sbin/init.d/rc3.d ln -s ../fetchmail S06fetchmail ln -s ../fetchmail K39fetchmail>From SuSE Linux 7.1 on, there is only one thing that still needs to be done:
chmod +x fetchmail insserv /etc/init.d/fetchmail
/etc/ppp/ip-up
:
#!/bin/sh # (c) '97, S.u.S.E. GmbH, Fuerth, Germany # Klaus Franken # 23.09.97 BASENAME=`basename $0` INTERFACE=$1 DEVICE=$2 SPEED=$3 LOCALIP=$4 REMOTEIP=$5 case "$BASENAME" in ip-up) /usr/bin/fetchmail -a >> /var/log/fetchmail 2>&1 ;; ip-down) ;; *) ;; esac
Find out whether the provider keeps the target address or rewrites it (usually to the mail account).
fetchmail
can forward the mail directly to the
MTA (sendmail, postfix).
Make sure the MTA assumes responsibility for the incoming mail.aka
or localdomains
. aka
replaces the
domain part with localhost
. On the other hand, localdomains
keeps the domain part, which means
that the MTA must be configured accordingly. If this is not done, the mail is not distributed locally
but is resent and comes back to the mailbox :-(. (mail loop!)
.fetchmailrc
may look somewhat like:
poll mail.provider.com protocol POP3 aka domain1 domain2 user asterix password adam is *The mail delivery via MTA works us usual; aliases can be defined in
/etc/aliases
, and a virtusertable (sendmail)
is set up
(mainly necessary if several users in your system receive mail with the same mail user
name, and only the domain part is diferent; in this case at least one of these addresses
must be rewritten to another local user).
Example:
The following mail addresses arrive in your mailbox:
name1@prov1.com
name1@prov2.com
Normally, these messages would all be forwarded to the local mailbox
name1 (or to a substitute mailbox stated in aliases
)
Accordingly, one of the addresses must first be assigned to another user.
For this purpose, use the following syntax in the file /etc/mail/virtusertable (sendmail)
:
name1@prov2.com localusernameThen execute
SuSEconfig
.
.fetchmailrc
):
set no bouncemailHowever, mail of this kind can not be allocated to individual users, as
fetchmail
and sendmail
can no longer determine
to whom the message was originally sent. Therefore, this kind of mail
goes to the postmaster
.fetchmail
in such a way that the respective
header is processed.envelope
.
.fetchmailrc
may look as
follows:poll mail.provider.com envelope Delivered-To: protocol POP3 aka domain1 domain2 user asterix password adam is *If you use
qmail
, make sure you start fetchmail
with the command-line option
--qvirtual qmailprefix-
.
fetchmail
has no possibility to identify
the recipient. The only possibility is to examine the mail header.
To do this, we suggest that you set up a special user (e.g. mailer
)
that forwards mail by means of a ~/.procmailrc
file.
Examples can be found under http://www.linuxdoc.org/HOWTO/mini/Offline-Mailing.html.