Using PHP and mini_sendmail

Some linux distributions do not include sendmail in their base installation. Other folks may not want to run sendmail. Either way, if you want to use PHP's mail() function and you do not have a mail server installed locally, you need to find another way for mail() to sucessfully send email from a PHP script. mini_sendmail is a good choice for a basic, "I only need to send mail for testing on my development server" type of environment.
  1. Download and compile mini_sendmail.
  2. Create a symbolic link, so it looks like sendmail really exists: ln -s /usr/local/sbin/mini_sendmail /usr/sbin/sendmail
  3. Edit your php.ini file to use appropriate options for sending mail: ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = /usr/sbin/sendmail -t -ftest@example.com -smail.example.com
  4. Restart apache and that's it.

Notes: I found I needed to supply the From address in the sendmail path; otherwise the mail server I was using would not send the email. I also found that I compiled PHP without setting up mini_sendmail first, so PHP kept giving me the error about mail() not being a declared function. I chose that as a sign to upgrade to PHP 5.2.2. Install mini_sendmail first, then install PHP.