OS X Localhost Mail Server Settings

Wiki

Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail, intended as an alternative to the widely used Sendmail MTA.

Postfix is released under the IBM Public License 1.0 which is a free software licence.

Originally written in 1997 by Wietse Venema at the IBM Thomas J. Watson Research Center and first released in December 1998, Postfix continues as of 2014 to be actively developed by its creator and other contributors. The software is also known by its former names VMailer and IBM Secure Mailer.

Postfix Official Website www.postfix.org

Modify the main PHP configuration file php.ini file, open the PHP mail() function to send mail function in Unix-like systems

$ sudo vim /usr/local/etc/php/5.5/php.ini

Modify

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

... to

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "env -i /usr/sbin/sendmail -t -i"

Then restart the Apache server or Nginx server.
Open Mail Service
Send E-mail mainly by the Mail Transfer Agent (MTA) mail transfer agent to achieve, there are common MTA Postfix, Sendmail, etc.
OS X system has been pre-installed Postfix service, we do not need to install once, just to start it.

$ sudo postfix start
postfix/postfix-script: starting the Postfix mail system

Check Postfix Running Status ( whether the process created )

$ ps -ef | grep postfix
    0  3131     1   0  1:15PM ??         0:00.02 /usr/libexec/postfix/master
  501  3268  1828   0  1:24PM ttys000    0:00.00 grep postfix

Check Postfix Install Path

$ which postfix
/usr/sbin/postfix

Test Send Mail

$ date | mail -s testing name[at]example.com

View Send Queue

$ mailq
Mail queue is empty

Open your inbox to check if there testing the title of the message.

PHP Mail() Function Test Mail

<?php
    $send = mail('name[at]example.com', 'My Subject', 'The test mail');
    if ($send) {
      echo 'true';
    } else {
      echo 'false';
    }
0.00 avg. rating (0% score) - 0 votes