Codingdomain.com

Automatic mail processing

Automatic download

Running getmail

It's time to test the configuration.

First getmail needs to be tested. Run the following commands to test getmail, and see what happens:

Testing getmail:
getmail --dont-delete                   # if you use ~/.getmail/getmailrc
getmail --dont-delete --rcfile filename # if you have separate v4 files

If everthing went file, you should find your e-mail messages in the folder ~/.maildir/new/.

If getmail indicates something is wrong, or your messages are not stored at all, verify your getmail configuration and check the maildrop log. I've placed those in ~/.getmail/maildrop.log.

Enable the cronjob

Finally, the automatic downloading can be enabled with a cronjob. Run crontab -e in the console to edit the crontab. You can also run kcron in KDE.

Crontab with getmail-3 command: "crontab -e"
# download my e-mail every half hour:
15,45 * * * *    getmail --quiet
Crontab with getmail-4 command: "crontab -e"
# download my e-mail every half hour:
15,45 * * * *    getmail --quiet --rcfile "rc_vdboor@hotmail" --rcfile "rc_vdboor@codingdomain"

Running getmail-3 manually is very easy, just type getmail. Using multiple rc-files with getmail-4 makes it more complex, but you might like this script:

getmail-4 helper script:
#!/bin/sh

ignore_warnings='DeprecationWarning|FutureWarning|HeaderParser|%s at 0x'

for account in vdboor@hotmail vdboor@gmail vdboor@codingdomain
do
  if [ "$1" = "--quiet" ]
  then
    getmail --quiet --rcfile "rc_$account" 2>&1 \
          | grep -vE "$ignore_warnings" 1>&2
  else
    echo ""
    getmail --rcfile "rc_$account" \
          | grep -vE "getmail version|GNU GPL|$ignore_warnings" \
          | sed -e 's/SimplePOP3Retriever:/Checking /'
  fi
done

This script can be saved as ~/bin/getallmail for example. Use chmod +x ~/bin/getallmail to enable the execution permissions. You can also replace the cron command with the script off course:

Crontab with script: "crontab -e"
# download my e-mail every half hour:
15,45 * * * *    ~/bin/getallmail --quiet

This will download the e-mail automatically twice each hour.

Final Recap

By using Maildrop, all e-mail messages are sorted automatically and checked for any signs of spam. With the configured IMAP server, e-mail messages can be shared between different e-mail clients.

Whenever you switch to another desktop, you'll see the same e-mail messages. Most webmail applications have build-in support for IMAP, so it's very easy to view the same e-mail messages with webmail as well. But most important: I hope it an exciting yourney! ;-)

blog comments powered by Disqus