Another way to get sendmail command maybe?

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Another way to get sendmail command maybe?

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :? :)
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Post 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
Post Reply