wiki:howto/SetupFetchmail

Version 8 (modified by martin.osx@…, 16 years ago) (diff)

typo

<- Back to the HOWTO section

How to set-up fetchmail

  • Audience: Advanced E-Mail setup
  • Requires: MacPorts >= 1.6, mail/fetchmail, shells/zsh-devel

Introduction

This How-to is part of the Fetchmail -> Postfix -> Dovecot advanced e-Mail set-up.

fetchmail fetchmail is program used to collect e-mail from internet service provider and transfers them to the local mail transfer agent for further distribution.

[wikipeadia:Fetchmail fetchmail] can collect mail from various sources and for multiple users. With the setup described here the user does not need to start an Email_Client for collection to happen. In fact the user does not even need to be logged in.

Installation

First set-up a mail storage and a mail transfer agent . See Dovecot and Postfix a possible set-up. Fetchmail will not work without and you can loose your mail if those components are not set-up properly.

Then install fetchmail with

port install zsh.devel
port install fetchmail +fetchmailconf +ssl 

or use the fetchmail which comes preinstalled.

Configuration

Note: Do not use any of the attached files without checking / changing them with your favourite text editor.

Step 1: create user

Fetchmail does not need root or normal iser privileges to run so it is suggested to create an unprivileged user and group for daemon based fetchmail configurations. You can use the Make_Fetchmail_User.command to do so.

Step 2: create directories

Dovecot need two directories to work with - one to store the run status, one for the log files. You can use the Make_Fetchmail_Directories.command to create the directories.

Depending on which fetchmail (macports or OSX) is used you might want to change the pathnames to better reflect you system set-up.

Step 3: set-up configuration

Next you need to set up fetchmailrc. You find the file in /opt/local/etc (macports) or /private/etc. The file should be owned by _fetchmail:_fetchmail and only be readable to _fetchmail an no one else.

As a starting point you can use fetchmailrc. You will need to add all your mail source to fetchmailrc.

Step 4: starting the daemon

Fetchmail is started using launchd which is controlled by the attached org.macports.fetchmail.plist.

Depending on which fetchmail (macports or OSX) is used you might want to change the pathnames to better reflect you system setup.

The attached Restart_Fetchmail.command command will stop and restart fetchmail which forces a re-read of the configuration files and triggers an immediate mail collection - quite helpful while debugging the system.

Step 5: testing the deamon

Before using fetchmail you should collect all your mail by conventional means.

After starting fetchmail you should check if the start was succesfull by checking the syslog:

$ syslog
Thu Jun  5 21:20:42 macpro sudo[42916] <Notice>:   martin : TTY=ttys001 ; PWD=/opt/local/Applications/Utilities ; USER=root ; COMMAND=/bin/launchctl unload -w /Library/LaunchDaemons/org.macports.fetchmail.plist
Thu Jun  5 21:20:42 macpro sudo[42917] <Notice>:   martin : TTY=ttys001 ; PWD=/opt/local/Applications/Utilities ; USER=root ; COMMAND=/bin/launchctl load -w /Library/LaunchDaemons/org.macports.fetchmail.plist
Thu Jun  5 21:20:42 macpro sudo[42919] <Notice>:   martin : TTY=ttys001 ; PWD=/opt/local/Applications/Utilities ; USER=root ; COMMAND=/bin/launchctl start org.macports.fetchmail
Thu Jun  5 21:20:42 macpro org.macports.fetchmail[42918] <Notice>: fetchmail: starting fetchmail 6.3.8 daemon 
Thu Jun  5 21:20:48 macpro org.macports.fetchmail[42918] <Notice>: fetchmail: sleeping at Thu, 05 Jun 2008 21:20:48 +0200 (CEST) for 1800 seconds

Last you send yourself a mail and trigger a mail collection with Restart_Fetchmail.command and then check if the mail arrived ok in your local mail storage.

Optional Parts

<- Back to the HOWTO section

Attachments (5)

Download all attachments as: .zip