fetchmail script

28 May

fetchmail script

We have wrote a small and nice script for Fetchmail (check it out). You can install the script in /etc/fetchmail.d directory, and then run the scheduled command that we wrote (put in /etc/cron.hourly to let it run hourly) to automate it. Also, you should edit /etc/crontab file to make it run more often (may be every 15 minutes). You should edit this sample configuration to your site settings.

We hope this is helpful to you

#!/bin/sh

# Add the users who responsible to run fetchmail. The fetchmail script
# can auto “awake” every 5 minutes by using “set daemon 600” option.
# Fetchmail seems died by itself after a while. So this cron job will
# re-enforce that the fetchmail will run every hour.

CONFIGDIR=/etc/fetchmail.d
SILENT=”Y”

# Make sure all files are set to 600 mode
chmod 600 $CONFIGDIR/*
OPTIONS=””
[ “$SILENT” = “Y” ] && OPTIONS=”-s”

cd $CONFIGDIR
LIST=`ls -1`
for i in $LIST; do
fetchmail $OPTIONS -f $CONFIGDIR/$i > /dev/null 2>&1
done