Page 1 of 1

[SOLVED] smtp gmail Swift_Connection_Exception

Posted: Thu Apr 12, 2007 2:57 pm
by hectorsc
I pulled this code off another thread and put in my info

Code: Select all

<php
  require("swift/Swift.php");
  require("swift/Swift/Connection/SMTP.php");
        $smtp = new Swift_Connection_SMTP('smtp.gmail.com',
                                                     Swift_Connection_SMTP::PORT_SECURE,
                                                     Swift_Connection_SMTP::ENC_TLS);
        $smtp->setUsername("xxxxx@gmail.com");
        $smtp->setPassword("xxxxxx");
        $swift = new Swift($smtp);   

       $message = new Swift_Message("subject", "body");



                           //Start a new list

                    //$recipients = new Swift_RecipientList();


                 //$recipients->addTo("xxxxxxx@hotmail.com"); //or we can just add the address




           $result = $swift->send($message, $recipients, new Swift_Address("xxxxxxxx@hotmail.com", "Hector Scout"));

       if (!$result){

           echo "error: ";

             }
            $swift->disconnect(); 
?>

I'm getting this error:

Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 40 and Error String 'Unable to find the socket transport "tls" - did you forget to enable it when you configured PHP?'' in C:\Program Files\php\PEAR\swift\Swift\Connection\SMTP.php:291 Stack trace: #0 C:\Program Files\php\PEAR\swift\Swift.php(220): Swift_Connection_SMTP->start() #1 C:\Program Files\php\PEAR\swift\Swift.php(97): Swift->connect() #2 D:\www\sendEmail.php(37): Swift->__construct(Object(Swift_Connection_SMTP)) #3 {main} thrown in C:\Program Files\php\PEAR\swift\Swift\Connection\SMTP.php on line 291

Any help?

Posted: Thu Apr 12, 2007 3:00 pm
by Chris Corbyn
PHP isn't compiled with OpenSSL. It needs to be or this wont work.

EDIT | I'm not sure how ssl works on windows. I think there will be an extension you need to enable.

Solved

Posted: Thu Apr 12, 2007 7:17 pm
by hectorsc
That did it. I just had to uncomment the "extension=php_openssl.dll" line in php.ini and it works now. Thank you much. Hooray!

Re: Solved

Posted: Fri Apr 13, 2007 4:52 am
by Chris Corbyn
hectorsc wrote:That did it. I just had to uncomment the "extension=php_openssl.dll" line in php.ini and it works now. Thank you much. Hooray!
Is it that simple? I'm glad someone clarified this since this is pretty common with the windows users and I don't run PHP on windows so have never really been able to provide a definitive answer. I'll document that :)