Page 1 of 1

Yet another Gmail issue

Posted: Tue Apr 17, 2007 4:33 pm
by IceComputer
I apologize for burdening you with yet another gmail problem, but I am unable to connect and truly wish to.
Forgive me if this is my mistake (and it most likely is), as I am new to PHP - I am a C (most variants though primarily C#) programmer.

Code: Select all

require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";

//Connect to Gmail (PHP4)
$smtp =& new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
$smtp->setUsername("xxxxxxxx@ice-computer.com");
$smtp->setPassword("xxxxxx");

$swift =& new Swift($smtp);

//Create the message
$message =& new Swift_Message("My subject", "My body");

//Now check if Swift actually sends it
if ($swift->send($message, "xxxxx@ice-computer.com", "xxxxx@ice-computer.com")) echo "Sent";
else echo "Failed";
I get the following when run locally:

Code: Select all

Fatal error:
Uncaught Error of type [swift_connection_exception] with message [The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 0 and Error String 'The operation completed successfully. ']
@0 swift::swift() in C:\Program Files\nusphere\phped\projects\Murray-Home\Swift\SwiftMailer.php on line 11
@1 swift::connect() in C:\Program Files\nusphere\phped\projects\Murray-Home\Swift\lib\Swift.php on line 109

in C:\Program Files\nusphere\phped\projects\Murray-Home\Swift\lib\Swift\Errors.php on line 99
I get the following when running on my host account:

Code: Select all

Fatal error:
Uncaught Error of type [swift_connection_exception] with message [The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 110 and Error String 'Connection timed out']
@0 swift::swift() in /home/content/h/e/n/henley1502/html/Swift/SwiftMailer.php on line 11
@1 swift::connect() in /home/content/h/e/n/henley1502/html/Swift/lib/Swift.php on line 109

in /home/content/h/e/n/henley1502/html/Swift/lib/Swift/Errors.php on line 99
Locally, this is running under PhpEd devServer.
My hosting account has ssl sockets open.

Any assistance would be greatly appreciated.
I will state that I am impressed with your code from an OOP standpoint.

Thanks,
Steven Henley

Posted: Tue Apr 17, 2007 4:51 pm
by Chris Corbyn
The host is blocking traffic, and your local computer is (probably) using a PHP version that has a known bug. That "The operation completed successfully" problem is a known bug with PHP, not Swift. Try changing PHP versions and check bugs.php.net. You'll find a fair amount of stuff on the issue.

Thanks

Posted: Tue Apr 17, 2007 4:55 pm
by IceComputer
Chris -

Thank you for the advice!
I would be satisfied if I could get it running locally and will switch to version 5.

I appreciate the prompt response.

Thanks,
Steven Henley