Enabling PHP’s mail() command to work with Kerio Connect on Mac OS X?

Using the PHP's mail() command with Kerio MailServer requires:

  • creating a symbolic link
  • changing the php.ini file
  • setting the permissions on the SendMail binary
  • disabling Postfix, and
  • configuring the Relay Control settings

Creating the symbolic link

  1. In Terminal, navigate to the directory /usr/sbin using: cd /usr/sbin
  2. Disable OS X's Sendmail binary using: sudo mv ./sendmail ./sendmail-orig
  3. Create the symlink using: ln -s /usr/local/kerio/mailserver/sendmail

Changing the php.ini file

  1. Using Terminal, navigate to the directory /etc using this command: cd /etc
  2. Rename php.ini.default to php.ini using: sudo mv php.ini.default php.ini
  3. Edit the php.ini file with the VI editor using: vi php.ini
  4. Used /sendmail, to quickly find the sendmail section of the php.ini file.

NOTES

Press J and K to move up and down and H and L to move to left and right in the VI editor.

  1. Press X to remove the semi-colon in front of sendmail_path.
  2. Press I to enter Insert mode.
  3. Change sendmail_path to sendmail_path = /usr/local/kerio/mailserver/sendmail -i -t
  4. Press ESC to exit Insert mode.
  5. Use w! in the terminal to save the changes.
  6. Use q! in the terminal to exit the VI editor.

Setting the permissions on the SendMail binary

  1. Using Terminal, navigate to the directory /usr/local/kerio/mailserver using this command: sudo cd /usr/local/kerio/mailserver
  2. Run this command to change the permissions on the SendMail binary: sudo chmod 755 sendmail
  3. Verify the permissions are correct using the command: ls -l sendmail

We are expecting this result: -rwxr-xr-x@ 1 root wheel 4252344 Dec 11 18:38 sendmail

NOTE

As of version 7.2.0 of Kerio Connect you will also need to make the following changes.

  1. Using Terminal, navigate to the directory /usr/local/kerio/mailserver using this command: sudo cd /usr/local/kerio/mailserver
  2. Run this command to change the permissions on the first file, sudo chmod 755 ktcrypto.0.9.8.dylib
  3. Run this command to change the permissions on the second file, sudo chmod 755 ktssl.0.9.8.dylib
  4. Verify the permissions are correct using the command: ls -l kt*
  5. Run this command to change the permissions of the mailserver directory, so the PHP can access the sendmail file located in this directory, sudo chmod 755 /usr/local/kerio/mailserver

The result should be:

-rwxr-xr-x 1 root wheel 3395124 Jul 18 15:44 ktcrypto.0.9.8.dylib

-rwxr-xr-x 1 root wheel 740656 Jul 18 15:44 ktssl.0.9.8.dylib

IMPORTANT

Please note that the permissions on these files are reset after upgrading Kerio Connect.

Disabling Postfix (for OSX 10.4-10.6)

Using Terminal, type this command: sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/org.postfix.master.plist

That single command should stop Postfix from trying to start on port 25.

Configuring the Relay Control settings

  1. While logged into the Kerio MailServer Admin Console, go to Configuration > SMTPSimple Mail Transport Protocol - An internet standard used for email transmission across IP networks. Server > Relay Control.
  2. Enable Users from IP addressAn identifier assigned to devices connected to a TCP/IP network. group and click Edit.
  3. Click Add.
  4. Name the Address Group Localhost.
  5. Select Host and key in 127.0.0.1 in the IP address field.
  6. Click OK.
  7. Click Apply and Close.
  8. Select the IP address group named Localhost.
  9. Click Apply.

You should now be able to use PHP's mail() command with Kerio MailServer.

Using Terminal, type this command to send a test email: echo test | mail -F admin@yourdomain.com

NOTE

The webserver application must run as root when executing the PHP script.