Page 1 of 1

Fatal error: Uncaught exception 'Swift_Connection_Exception'

Posted: Mon Apr 02, 2007 7:08 pm
by vpman321
When i use SwiftMailer, certain email addresses will cause the following Fatal Error to ouput and kill the script. UIntil i remove the email address from the db, it will always give this error ( i loop through db records and send a message to each email)..any ideas what can be done to make sure the script doesnt die when this error comes up? I am running 3.1.2 for PHP5...

Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'There was a problem reading line 1 of an SMTP response. The response so far was:<br />[]. It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps?' in /home/wsuaa1/www/myalumnicommunity.com/siteadmin/lib/Swift/Connection/SMTP.php:232
Stack trace:
#0 /home/wsuaa1/www/myalumnicommunity.com/siteadmin/lib/Swift.php(307): Swift_Connection_SMTP->read()
#1 /home/wsuaa1/www/wsualumnicommunity.com/siteadmin/lib/Swift.php(381): Swift->command('RCPT TO: <kelly...', 250)
#2 /home/wsuaa1/www/myalumnicommunity.com/siteadmin/pages/newsletters/startqueue.php(185): Swift->send(Object(Swift_Message), 'kellyt@dhcpo.ci...', Object(Swift_Address))
#3 {main}
thrown in /home/wsuaa1/www/myalumnicommunity.com/siteadmin/lib/Swift/Connection/SMTP.php on line 232

Posted: Tue Apr 03, 2007 1:22 am
by Chris Corbyn
My email wrote:This usually happens when you overload the SMTP server or the web server but it may also occur if the SMTP server is configured to do reverse name lookups which can take a while. Increase the timeout on the connection to 30 seconds or so:

Code: Select all

$conn = new Swift_Connection_SMTP("foo");
$conn->setTimeout(30);

$swift = new Swift($conn);
Let me know if that doesn't help you ;)

Posted: Tue Apr 03, 2007 1:29 am
by Chris Corbyn
By the way, there's a reason Swift uses exceptions:

Code: Select all

foreach ($the_recipients as $recipient)
{
    try {
        $swift->send( ... );
    } catch (Exception $e) {
        do_something_with_failed($recipient);
        $swift->reset();
    }
}