Page 1 of 1

The SMTP connection failed to start [localhost:25]

Posted: Fri Apr 11, 2008 5:37 pm
by meti_alb
Hi there,

I ve been having no problems with swiftmailer till I discovered today that in one of my websites there is actually an error:

Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection failed to start [localhost:25]: fsockopen returned Error Number 111 and Error String 'Connection refused'' in /hsphere/local/home/albstream/maasbesa.org/admin/swiftmail/lib/Swift/Connection/SMTP.php:309 Stack trace: #0


The script that generates the above error is the following

Code: Select all

//set connection
        $smtp = new Swift_Connection_SMTP("smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS);
        $smtp->setUsername('email@domain.com');
        $smtp->setPassword('password');
        $swift = new Swift($smtp);
        
        //set message
        $mesazhi = new Swift_Message("Contact Form - ".$subject,$comments);
        $mesazhi->setReplyTo($email);
        
            if ($swift->send($mesazhi, "recipient@asdf.com",'sender@gmail.com'))
            {   
                $swift->disconnect();
                header("location: contact.php?msg=sent");
            }   
            else { 
                echo "Not Sent!.";
            }
I contacted the host (ixwebhosting) and tried to explain them that they were probably blocking port 25. But they replied that it's my computer firewall or probably the ISP which I think is irrelevant since the script is in ixwebhosting connecting to smtp.gmail.com and not on my pc.

Any ideas what the problem could be?

Note: the same script has been working for a while. I know that ixwebhosting had some big maintenance two weeks ago and I wonder if this is a problem on their side ??

Re: The SMTP connection failed to start [localhost:25]

Posted: Sat Apr 12, 2008 12:42 am
by Chris Corbyn
The error is regarding localhost... Your code is trying to use Gmail.

Do you have any code anywhere else? The rest of the stack trace would be useful :)