Fetchmail
Fetchmail dient zum Abholen von Email aus externen Mailboxen (POP3 oder IMAP) und Übergeben der Email z.B. an einen lokalen Email-Server wie Postfix.
Fetchmail Konfiguration
Im Homeverzeichnis des Users, der Fetchmail startet, muss die Datei .fetchmailrc erstellt werden.
Beispiel:
# Configuration created by fetchmailconf set postmaster "user1" set bouncemail set no spambounce set properties "" poll pop.domain1.de with proto POP3 user 'user0815' there with password 'xxx' is 'user1' here options fetchall ssl poll pop.domain2.com with proto POP3 user 'user0816' there with password 'xxx' is 'user1' here options fetchall ssl poll pop.domain3.de with proto POP3 user 'user0817' there with password 'xxx' is 'user1' here options fetchall ssl skip pop.domain4.com with proto POP3 user 'user0818' there with password 'xxx' is 'user1' here options keep ssl skip pop3.domain5.de with proto POP3 user 'user0819' there with password 'xxx' is 'user1' here options fetchall ssl
Hinweise:
- Emails für Einträge mit "keep" werden auf dem Server nicht gelöscht
- Einträge mit "skip" werden übergangen, wenn fetchmail ohne Angabe eines Servers aufgerufen wird.
Fetchmail aufrufen
Abholen aller Emails gemäß $HOME/.fetchmailrc (außer Server mit "skip"-Eintrag):
/usr/bin/fetchmail
Abholen von einem Server mit "skip"-Eintrag:
/usr/bin/fetchmail pop.domain4.com /usr/bin/fetchmail pop.domain5.com
Automatisierung
Hinweise:
- Fetchmail darf pro User nur einmal (zur gleichen Zeit) laufen !
Scripts
- /home/user1/bin/fetchmail-user1
#!/bin/bash # Eintrage in fetchmail-log machen echo "######################################" >> /var/tmp/fetchmail date >> /var/tmp/fetchmail # dann fetchmail starten /usr/bin/fetchmail >> /var/tmp/fetchmail 2>&1
- /home/user1/bin/fetchmail-rest
#!/bin/bash # Eintrage in fetchmail-log machen echo "######################################" >> /var/tmp/fetchmail date >> /var/tmp/fetchmail # dann fetchmail starten # holt nur Emails vom angegebenen Server, auch wenn dieser auf "skip" steht in rc file. /usr/bin/fetchmail pop.domain4.com >> /var/tmp/fetchmail 2>&1 /usr/bin/fetchmail pop.domain5.com >> /var/tmp/fetchmail 2>&1
Cronjob
Einträge als Cronjobs in /etc/crontab:
# Fetchmail darf pro user nur einmal laufen ! 0,5,10,15,20,25,30,35,40,45,50,55 * * * * user1 /home/user1/bin/fetchmail-user1 3,33 * * * * user1 /home/user1/bin/fetchmail-rest