10.4: Enable client POP3/IMAP after upgrade

May 09, '05 01:47:00PM

Contributed by: spiff

If you had Postfix Enabler installed on a 10.3 client system that you have upgraded, you may find that your mail setup no longer works as expected. No surprise here, since Apple has made some under-the-hood changes with Tiger and how it runs start-up items and services. After a bit of digging around, I finally got my mail server for Tiger client working again. Here is what is needed to get it to work again.

Note: this is a fairly long tip since it includes file listings needed, but the process itself should be relatively straight forward.

[robg adds: I haven't tested this one...]

The first four steps check that the upgrade from 10.3.X hasn't deleted or moved the files needed to get this to work. The Tiger-specific details follow at step five and beyond.

  1. First thing to check is that you still have an entry in /etc/hostconfig which says:
    MAILSERVER=-YES-
  2. Check that you still have the Postfix startup item installed. It should be either in /System/Library/Startup Items or more properly, since this is a non-Apple add-in to the system, it should be in /Library/Startup Items. The contents of the Postfix startup item folder should be:
    /Library/Startup Items/Postfix/Postfix
    /Library/Startup Items/Postfix/StartupParameters.plist
    
    Full contents of each of these files is located at the end of this tip.

  3. Make sure that your POP and IMAP binaries are still in place where they were in 10.3. In my case, they should have been in /usr/local/libexec, thus the listing of that directory should be:
    /usr/local/libexec/imapd
    /usr/local/libexec/ipop3d
    
  4. Make sure your postfix configuration is still valid. So all the files in /etc/postfix from the previous installation should still be there, and still valid from the previous installation in 10.3. So far so good, nothing new really for Tiger. Now we get into the new stuff.

  5. Create a few extra files for use by Tiger and its startup processes, so that you can retrieve mail from your working SMTP server. If you only use POP, go to Part A. Likewise, if you only use IMAP, go to Part B. Note that though Apple seems to support the /etc/xinetd.d/ startup sequence for internet daemons in Tiger, I could not get it to work properly with existing stuff, hence the following workaround/solution. You will be creating new files in /Library/LaunchDaemons.

    Part A - POP3 Access
    First file to create is for POP access. Open the terminal and do the following:
     sudo pico /Library/LaunchDaemons/pop3.plist 
    At the following screen, paste in this content. Hit Control-X to quit out of pico and save changes.

    Part B - IMAP Access

    If you are planning on using IMAP, then the following will enable IMAP. In Terminal, type:
     sudo pico /Library/LaunchDaemons/imap3.plist
    
    Paste in this content. Quit out of pico (Control-X) and save changes.

    Part C

    Now that the files are created, they need the correct permissions. Either in the Finder's info box (Command-I) or with Terminal:
     sudo chown root:admin /Library/LaunchDaemons/*
    
    This will change the files' ownership to root and admin.
You're done! Now you've done what is needed to get Tiger Client to support incoming, and outgoing mail through SMTP and POP/IMAP.

Enabling SSL versions of POP3 and IMAP
Note: For simplicity's sake, we have just created the startup instructions just for non-encrypted (non-SSL) POP3 and IMAP connections. The same basic idea applies for POP3S and IMAPS connections except you have to make sure you have the security certificates transferred over as well from your previous installation.

SSL Certificates:
/System/Library/OpenSSL/certs/imapd.pem
/System/Library/OpenSSL/certs/ipop3d.pem
/System/Library/OpenSSL/certs/smtpd.pem
If you want to use SSL-enabled POP/IMAP, the same model plists listed above apply except make sure of the following:

IMAPs

LaunchDaemon file should be created as /Library/LaunchDaemons/imap3s.plist with the following changes from the model IMAP3.plist listed above
<key>Label</key>
      <string>edu.washington.imapds</string>
and the "Listener" part is changed to:
<key>SockServiceName</key>
      <string>imap3s</string>
POP3s
Replace pop3 in the /Library/LaunchDaemons/pop3s.plist with pop3s in both the Label and Listener.

Postfix StartupItems folder listing
As mentioned earlier in this hint, here are the Postfix StartupItem listings:

/Library/StartupItems/Postfix/StartupItems/StartupItems.plist
should read:
{
  Description   = "Postfix mail server";
  Provides      = ("SMTP");
  Requires      = ("Resolver");
  Uses          = ("Network Time", "NFS");
  Preference    = "None";
  Messages =
  {
    start = "Starting Postfix";
    stop  = "Stopping Postfix";
    restart  = "Reloading Postfix Configuration";
  };
}
and the /Library/StartupItems/Postfix/StartupItems/postfix listing should read:
#!/bin/sh

. /etc/rc.common

StartService ()
{
    if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then
            ConsoleMessage "Starting mail services"
       /usr/sbin/postfix start
    elif [ "${MAILSERVER:=-NO-}" = "-AUTOMATIC-" ]; then
         /usr/sbin/postfix-watch
    fi
}

StopService ()
{
   ConsoleMessage "Stopping Postfix mail services"
       /usr/sbin/postfix stop
        killall -1 postfix-watch 2> /dev/null
}

RestartService ()
{
    if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then
     ConsoleMessage "Reloading Postfix configuration"
      /usr/sbin/postfix reload
    else
    StopService
    fi
}

RunService "$1"
Permissions for both files should be owner: root and group: admin

Comments (10)


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