Most of the time when running a web server you will need to send mail from php applications. What happens if you don’t have sendmail on that machine or if you run apache in a chroot ?
Then you will need to send mail via smtp. And the best way is to use pear for this. It’s quite easy to change mail() with pear code:
$params[‘host’] = ‘127.0.0.1’; // change this to your smtp server
$mail =& Mail::factory(‘smtp’, $params);
$headers = array(“From”=>”email@example.com”, “Subject”=>”Mail subject”);
$body = $msg;
$mail->send(“firstname.lastname@example.org”, $headers, $body);
Installing the necessary pear classes is done like this:
pear install Mail
pear install Net_SMTP
Happy mail sending.