Page 1 of 1

error catching issue

Posted: Tue Apr 14, 2009 9:06 pm
by frankie
I'm trying to have swift mailer be as fail proof as possible (you've sure made it very easy! - great work) but I am not beeing able to cope when sendmail is down. Given the following example:

Code: Select all

// use all transports for failover safety
$transport_smtp = Swift_SmtpTransport::newInstance("localhost");
$transport_sendmail = Swift_SendmailTransport::newInstance();
$transport_native = Swift_MailTransport::newInstance();
        
try {
    $this->swift = new Swift_Mailer(Swift_FailoverTransport::newInstance(array(
        $transport_smtp,
        $transport_sendmail,
        $transport_native
    )));
} catch (Swift_TransportException $e) {
    echo "Could not initialize any transporter (smtp, sendmail and nativemail failure!)";
    return false;
}
If I turn sendmail off (/etc/rc.d/init.d/sendmail stop) the catch part is not triggered and the function keeps running. I do get a php error:

A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to localhost:25 (Connection refused)
Filename: Transport/StreamBuffer.php
Line Number: 243

Am I doing it all wrong?

Thank you,
Frankie

Re: error catching issue

Posted: Thu Apr 16, 2009 7:30 am
by Chris Corbyn
The exception is thrown from send() in version 4.

Re: error catching issue

Posted: Thu Apr 16, 2009 8:18 am
by frankie
Thanks Chris!

I owe a lunch. I'm planning to visit Australia in the next couple of years - vacation - so, if your up to it, I'll contact you then.

Thanks once again and congrats on the great software library you developed!

Francisco