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
- In Terminal, navigate to the directory 
/usr/sbinusing:cd /usr/sbin - Disable OS X's Sendmail binary using: 
sudo mv ./sendmail ./sendmail-orig - Create the symlink using: 
ln -s /usr/local/kerio/mailserver/sendmail 
Changing the php.ini file
- Using Terminal, navigate to the directory 
/etcusing this command:cd /etc - Rename 
php.ini.defaulttophp.iniusing:sudo mv php.ini.default php.ini - Edit the php.ini file with the VI editor using: 
vi php.ini - 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.
- Press X to remove the semi-colon in front of 
sendmail_path. - Press I to enter Insert mode.
 - Change 
sendmail_pathtosendmail_path = /usr/local/kerio/mailserver/sendmail -i -t - Press ESC to exit Insert mode.
 - Use 
w!in the terminal to save the changes. - Use 
q!in the terminal to exit the VI editor. 
Setting the permissions on the SendMail binary
- Using Terminal, navigate to the directory 
/usr/local/kerio/mailserverusing this command:sudo cd /usr/local/kerio/mailserver - Run this command to change the permissions on the SendMail binary: 
sudo chmod 755 sendmail - 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.
- Using Terminal, navigate to the directory 
/usr/local/kerio/mailserverusing this command:sudo cd /usr/local/kerio/mailserver - Run this command to change the permissions on the first file, 
sudo chmod 755 ktcrypto.0.9.8.dylib - Run this command to change the permissions on the second file,
sudo chmod 755 ktssl.0.9.8.dylib - Verify the permissions are correct using the command: 
ls -l kt* - 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
- 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.
 - Enable Users from IP addressAn identifier assigned to devices connected to a TCP/IP network. group and click Edit.
 - Click Add.
 - Name the Address Group Localhost.
 - Select Host and key in 
127.0.0.1in the IP address field. - Click OK.
 - Click Apply and Close.
 - Select the IP address group named Localhost.
 - 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.