smtp connection failure

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
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

smtp connection failure

Post by s.dot »

I've just recently been getting this message, without changing any files on the server. I can send an email to myself using thunderbird so I know the server is responsive and running. But my emails through my web site are not sending.

Code: Select all

Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection failed to start [smtp.1and1.com:25]: fsockopen returned Error Number 42 and Error String ''' in /home/bluesurf/public_html/lib/Swift/Connection/SMTP.php:309
What could have happened?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: smtp connection failure

Post by s.dot »

OK, so now it is working. Odd =/
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: smtp connection failure

Post by s.dot »

If I wrap the code up like this..

Code: Select all

try
{
    if ($swift->send())
    {
        $numSent++;
    }
} catch (Exception $e) 
{
    //do nothing
}
Will this prevent fatal errors from happening in the future?

I want to allow the script to continue if the email sending fails.

I would try it but this system is live.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: smtp connection failure

Post by Oren »

If the fatal errors you are getting are caused by uncaught exceptions then yes, otherwise - no.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: smtp connection failure

Post by Chris Corbyn »

scottay, you'd have to put some logic in the catch() block to ensure Swift is restarted and/or the error is handled. Swift wouldn't stop if it could easily carry on (in the case the connection was refused so swift couldn't just carry on ignoring that fact ;))
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: smtp connection failure

Post by s.dot »

Well, on the pages where I'm just sending a single email, then it would work.. right? I mean swift would error out (because it can't connect) but the rest of my script would continue.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: smtp connection failure

Post by Chris Corbyn »

scottayy wrote:Well, on the pages where I'm just sending a single email, then it would work.. right? I mean swift would error out (because it can't connect) but the rest of my script would continue.
Correct :)
Post Reply