I have the following script:


$recip = "me <me@yahoo.com>";
$strSubject = "test subject";
$strMessage = "test message";
$crlf = "\n";
$headers = array('From'          => $recip,
        'Return-Path'   => $recip,
        'Subject'       => $strSubject);

$mime = new Mail_mime($crlf);
$body = $mime->get();
$headers = $mime->headers($headers);
$smtp_params["host"] = "localhost";
$smtp_params["port"] = "25";

$mail =& Mail::factory("smtp", $smtp_params);
//$mail =& Mail::factory('mail');
$confirmation = $mail->send($recip, $headers, $body);
if ($confirmation) echo "accepted";
else echo "not accepted";

I have postfix running on the server. The script gives me no php errors and postfix shows nothing in log when I execute. when I swich the factory lines (switch the commenting) the script sends email and postfix logs the connection. I put default master.cf and main.cf files for postfix, reloaded and restarted.

I am not very well versed with the email side of servers. Any info would be great. Might there be any error messages stored somewhere concerning the failure to connect? I've tried various $smtp_params options but I'm just shooting in the dark. Any ideas would be greatly appreciated.

1 Answer 1


On most machines with postfix installed, there's a local sendmail equivalent file, and unless you configure postfix differently, it will act as a local receiver for mail, meaning you shouldn't need to specifically configure postfix to accept mail in that manner as long as you send well formatted email with the necessary headers.

Basically, if it's local, there's no need to configure pear as though the mail server is on another machine.


  • Thank you, Nick, for your response. My problem stems from the fact that I have another server which is running fastcgi in a chroot jail. I'm trying to avoid puting sendmail and all its dependancies into the jail. So I am trying to get the pear smtp mail function working on my less-secure server and hopefully be able to implement the same method in the chroot jail for production purposes.
    – laertiades
    Feb 1, 2013 at 18:36
  • I am embarassed to say what I was doing wrong: when I changed php.ini to allow fopen() I forgot to restart php-fpm. Problem solved
    – laertiades
    Feb 1, 2013 at 21:00
  • Glad you got it worked out..
    – NickW
    Feb 4, 2013 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.