Skip to content
rthrd edited this page Nov 16, 2014 · 3 revisions
Fetchmail is a full-featured, robust, well-documented remote-mail retrieval
and forwarding utility intended to be used over on-demand TCP/IP links
(such as SLIP or PPP connections). It supports every remote-mail protocol
now in use on the Internet: POP2, POP3, RPOP, APOP, KPOP, all flavors of
IMAP, ETRN, and ODMR. It can even support IPv6 and IPSEC.

http://www.fetchmail.info

As each message is retrieved, fetchmail delivers it to the local Mail Transfer Agent (e.g. sendmail, exim, postfix)

If your fetchmail configuration sets a local Mail Delivery Agent (e.g. procmail, maildrop), it will be used directly.

On laptops or home computers a full fledged email server is sort of overkill, and the combination of fetchmail and a MDA (I use procmail here) is quite easy to configure.

Configuration

###Fetchmail

Fetchmail comes with fetchmailconf, a graphical front end to set up the configuration in ~/.fetchmailrc.

Console junkies may prefer to get their editor ready and study http://www.fetchmail.info/fetchmail-man.html#31 to create it manually.

The most simple ~/.fetchmailrc would be (substitute <...> including the <> with your data):

poll <mail-provider>
	proto <auto|pop3|imap|>
	user "<your user name>"
	pass "<MostSecret>"
	is <local-user-name>

Other usefull keywords are:

  • ssl: use ssl
  • keep: keep mail on server
  • mda "/usr/bin/procmail -d %s" pass mail to procmail for delivery to mailbox

###Procmail

http://www.procmail.org

Procmail is a mighty mail filtering, sorting and processing utility.

Using only one mailbox the most simple .procmailrc is:

MAILDIR=/var/mail
DEFAULT=/path/to/mailbox/

The trailing slash is mandatory for maildir mailboxes.

Invoking

Fetchmail can be run in demon mode as system service polling in regular intervalls.

I prefer to call fetchmail from the before-poll hook:

if (@last_fetchmail_time || Time.at(0)) < Time.now - 900
  say "Running fetchmail..."
  system "fetchmail > /dev/null 2>&1"
  say "Done running fetchmail."
end
@last_fetchmail_time = Time.now

using the following setting in ~/.sup/config.yaml:

:poll-intervall: 300
Clone this wiki locally