Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Using fetchmail with sendmail for POP3 UNIX
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!
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[10,864 views]  

Using fetchmail with sendmail for POP3 | 2 comments | Create New Account
Click here to return to the 'Using fetchmail with sendmail for POP3' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
"bug"fix for the proposed method
Authored by: geoffsaulnier on May 31, '02 11:18:22PM
Ouch - Demon's mailserver puts a load of crud into the Received lines of the mail messages, and fetchmail cannot decipher these sometimes. For example, I forward all my mail to my demon mail address from geoffsaulnier@mac.com so this mail gets the recipient part translated to geoff@node.demon.co.uk which is shown in the recipient line. Fetchmail, though, rejects these lines because the cruddy names used my Demon's mailserver are not aliases of the mailserver pop3.demon.co.uk The fix is to change the /etc/mail/fetchmailrc file as follows:
set daemon 120
poll pop3.demon.co.uk proto pop3
   aka demon.net
   aka mailstore
   localdomains node.demon.co.uk mailstore
   user "node" pass "nodepassword"
   to * here
   fetchall
The aka lines tell fetchmail that the cruddy "by" parts of the Received lines are actually just other names for Demon's mailserver(s). This now works properly! Cheers, Geoff.

[ Reply to This | # ]
BTW this works with 10.3 "postmail"
Authored by: morphis on Feb 19, '04 10:26:22AM
A little edit to the startup item /Library/StartupItems/fetchmail/fetchmail
#!/bin/sh

. /etc/rc.common

StartService ()
{
    if [ "${MAILMAN:=-NO-}" = "-YES-" ]; then
            ConsoleMessage "Starting fetchmail services"
            /usr/bin/fetchmail --fetchmailrc /etc/mail/fetchmailrc  --logfile /var/log/mail.log --silent
    fi
}

StopService ()
{
        ConsoleMessage "Stopping fetchmail services"
        /usr/bin/fetchmail --quit
}

RestartService ()
{
return 0
}

RunService "$1"
And to /Library/StartupItems/fetchmail/StartupParameters.plist
{
  Description   = "Fetchmail mail server";
  Provides      = ("fetchmail");
  Requires      = ("Resolver");
  Uses          = ("Network Time", "NFS");
  Preference    = "None";
  Messages =
  {
    start = "Starting Fetchmail";
    stop  = "Stopping Fetchmail";
  };
}
Remember man fetchmail for help
Otherwise your brain may/will explode

[ Reply to This | # ]