Fatal error: Uncaught exception 'Swift_Connection_Exception'

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
vpman321
Forum Newbie
Posts: 1
Joined: Mon Apr 02, 2007 7:03 pm

Fatal error: Uncaught exception 'Swift_Connection_Exception'

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

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

Post 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();
    }
}
Post Reply