Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following script:

<?php
include('Mail.php');
include('Mail/mime.php');

$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);
$mime->setTXTBody($strMessage);
$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.

share|improve this question
add comment

1 Answer

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.

Nick

share|improve this answer
    
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. –  Jesse Goodfellow Feb 1 '13 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 –  Jesse Goodfellow Feb 1 '13 at 21:00
    
Glad you got it worked out.. –  NickW Feb 4 '13 at 10:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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