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”=>”firstname.lastname@example.org”, “Subject”=>”Mail subject”);
$body = $msg;
$mail->send(“email@example.com”, $headers, $body);
Installing the necessary pear classes is done like this:
pear install Mail
pear install Net_SMTP
Happy mail sending.
you forgot to mention that on top of these you mast set
include_path = “path/to/your/pear/install” in php.ini (near line 400)
Ops. True 🙂