Page 1 of 1

Another way to get sendmail command maybe?

Posted: Thu Jun 21, 2007 1:22 pm
by Technocrat
I tried to get the sendmail class to auto detect the command in PHP 4 and it kept failing to do so. So I found a this to work:

Code: Select all

$sendmail_path = @ini_get('sendmail_path');    //Find the sendmail_path in the ini
        $sendmail_path = str_replace(' -i', '', $sendmail_path);   //If there is a -i get rid of it
        if (function_exists('proc_open') && !empty($sendmail_path)) {   //If the proc_open function exists and we have something in the sendmail path
            $swift =& new Swift(new Swift_Connection_Sendmail($sendmail_path));   //Try it
        }
I had to add the -i removal because it would cause swift to crash. I don't know what the -i does. Of course some hosts have sendmail on their box but it's not configured. So this is not a full proof way of doing it.

I did run into the fact that sendmail stop() was also getting called twice for some reason. This in turn cased the foreach to fail. To combat that I had to put it inside an is_array if statement.

Posted: Thu Jun 21, 2007 1:29 pm
by Chris Corbyn
stop() should only be called once as of the last two or three releases. Are you running an older version maybe?

Thanks for the snippet too :) I could have sworn I used to have ini detection in there :? :)

Posted: Thu Jun 21, 2007 1:32 pm
by Technocrat
No 3.2.6 though he had 3.2.4 (or 3 maybe) before and I upgraded when the problem first started. So got me. But I am having a problem with Sendmail not working correctly and I am typing it up write now in a new post