mini_sendmail for PHP mail

Based on http://www.rufdesigns.com/node/82

Some linux distributions, like FREESCO, do not include sendmail in their base installation. Other folks may not want to install the exim package. 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. In that case this may be the solution for you!

I've compiled mini_sendmail that you can install on your FREESCO like so:

cd /pkg/sbin
snarf -n http://dingetje.homeip.net/downloads/mini_sendmail
chmod +x mini_sendmail

Next thing to do is to edit your /usr/local/lib/php.ini and locate and change the sendmail_path line 1) to look like this:

sendmail_path = /pkg/sbin/mini_sendmail -t -fsomeone@example.com -smail.isp.com

where someone is a valid (i.e. webmaster) mail address and mail.isp.com is the SMTP mail server of your ISP.

Finally restart Apache with rc_httpd restart and test with the next simple PHP test script:

<?
$to = "someone@testme.com";
$from = "webmaster@your.domain";
$sub = "My First PHP Email";
$msg = "Hello World from mini_sendmail!";
mail($to, $sub, $msg, "From: $from");
?>

Make sure to edit this script and change the to and from addresses to some valid email addresses you have access to!

You can also verify the sendmail_path setting of your PHP by looking at the output of the next simple PHP script:

<?
phpinfo();
?>

Have fun! ā€” dingetje 2007/06/11 09:12

1) Default the sendmail_path line is commented out in php.ini and defaults to ā€/usr/bin/sendmail -t -iā€
 
freesco/howtos/mini_sendmail.txt (20192 views) · Last modified: 2007/06/19 16:43 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki