Using fetchmail with sendmail for POP3

May 25, '02 09:54:26AM

Contributed by: geoffsaulnier

My setup is that my ISP (Demon) provide me with a node which is also the name of the user that my mail account belongs to on their server. In other words, email will be geoff@node.demon.co.uk, my web address would be www.node.demon.co.uk, etc, but I have to log on to the mail server as user node. This means that I can have an infinite number of email addresses set up, but all the mail gets delivered at the ISP's end to the node mailbox and, when I retrieve it, I have to distribute it to the various accounts on my mac (me, the wife, friends and ex roomies, etc).

On my mac at home, I was downloading mail by SMTP using sendmail, after a brief struggle configuring it, and all was well.

Then, I got Demon's ADSL broadband connection. This does not allow you to download mail by anything other than POP3, which sendmail doesn't support. So, I opted for fetchmail.

Read the rest of the article to see how I set it up...

In /etc/mail I created a file called fetchmailrc with permissions 0600, owned by root:wheel. Contents:

set daemon 120
poll pop3.demon.co.uk proto pop3
localdomains node.demon.co.uk
user "node" pass "password" to * here fetchall
This runs fetchmail as a daemon as root, polls for mail on the mailserver every two minutes and passes it without changing it at all, as if it was still on the server, to the SMTP listener at port 25. This happens to be sendmail in my case, with the same sendmail.cf that I had before the change, and run by its Startupitems setup as sendmail -bd -q2m.

I tar-ed and copied the sendmail Startupitems directory to make a Fetchmail equivalent and changed every single place that contained "sendmail" to "fetchmail" and changed the actual startup line appropriately for what I wanted. Here is the file:
#!/bin/sh

. /etc/rc.common

##
# Start mail server
##

if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Starting fetchmail services"
/usr/bin/fetchmail --fetchmailrc /etc/mail/fetchmailrc --logfile /var/log/mail.log --silent
fi
This makes sure that fetchmail logs where I want it to and uses the root (global) fetchmailrc and doesn't spew too much into the logfile.

Also, here is the StartupParameters.plist file:
{
Description = "Fetchmail mail server";
Provides = ("POP3");
Requires = ("Resolver");
Uses = ("Network Time", "NFS");
Preference = "None";
Messages =
{
start = "Starting Fetchmail";
stop = "Stopping Fetchmail";
};
}
Fetchmail hands all the incoming mail off to sendmail and sendmail distributes it to the relevant /var/mail files as it did before - it doesn't know that anything has changed!

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2002052509542613