1-888-77-Kerio
Home » Categories » Kerio Connect » OS X
Icon Printer Icon Email      Icon Twitter Icon Digg Icon Stumbleupon Icon de.icio.us Icon FaceBook

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

Summary

Using the PHP's mail() command with Kerio MailServer requires (a) creating a symbolic link, (b) changing the php.ini file, (c) setting the permissions on the SendMail binary, (d) disabling Postfix, and (e) configuring the Relay Control settings.

Creating the symbolic link

  1. Using Terminal, navigate to the directory /usr/sbin using this command: cd /usr/sbin
  2. Disable OS X's Sendmail binary using this command: sudo mv ./sendmail ./sendmail-orig
  3. Create the symlink using this command: 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 this command: sudo mv php.ini.default php.ini
  3. Edit the php.ini file with the VI editor using this command: vi php.ini
  4. Type the command /sendmail to quickly find the sendmail section of the php.ini file.

    Navigation tips
    Use the letter j or k to move up or down in the VI editor.
    Use the letter h or l to move to the left or the right in the VI editor

  5. Use the letter x to remove the semi-colon in front of sendmail_path
  6. Click on the letter I to enter Insert mode.
  7. Change sendmail_path to look like this: sendmail_path = /usr/local/kerio/mailserver/sendmail -i -t
  8. Click on the ESC key to exit Insert mode.
  9. Use this command save the changes :w!
  10. Use this command to exit the VI editor :q

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

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


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 → SMTP Server → Relay Control.
  2. Enable "Users from IP address group" and click on the Edit button.
  3. Click Add
  4. Name the Address Group Localhost
  5. Select Host and type 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
 

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


comments powered by Disqus