Fatal error:
Uncaught Error of type [swift_connectionexception] with message [The SMTP connection failed to start [tls://smtp.gmail.com]: fsockopen returned Error Number 0 and Error String 'Success']
@0 swift::swift() in /home/myDir/public_html/swiftmail/SwiftMailer.php on line 28
@1 swift::connect() in /home/myDir/public_html/swiftmail/Swift.php on line 109
in /home/myDir/public_html/swiftmail/Swift/Errors.php on line 99
<?php
//Load in the files we'll need
require_once "Swift.php";
require_once "Swift/Connection/SMTP.php";
require_once "Swift/Authenticator/LOGIN.php";
//Start Swift
//$conn->attachAuthenticator(new Swift_Authenticator_LOGIN());
$smtp =& new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN());
$smtp->setUsername("uid@domain.tld");
$smtp->setPassword("Uid_p@ssw0rd");
$smtp->setTimeout(2);
$swift =& new Swift($smtp); /* Line 28 where it shows the error*/
//$swift =& new Swift($conn);
//Create the message
$message =& new Swift_Message("My subject", "My body");
//Now check if Swift actually sends it
if ($swift->send($message, "2@gmail.com", "fr0m@gmail.com"))
{
echo "Sent";
$swift->disconnect();
}
else echo "Failed";
?>
That error is a bug with certain versions of PHP. fsockopen() is failing to connect, but the "success" status shouldn't be there because there's no socket created. It's an implementation detail issue. You would be best advised to speak to your host. It may be that TLS is not enabled in their version of PHP.
You are able to send mail through gmail using TLS and phpMailer?
PhpMailer also uses fsockopen, so it's not that if it's the same server. Could I suggest you remove the 2 second timeout you've set?
It defaults to 15sec, and I can't see that setting it to 2sec serves any useful purpose other than to potentially cause problems and error messages like the one you are getting.
chuckl wrote:You are able to send mail through gmail using TLS and phpMailer?
PhpMailer also uses fsockopen, so it's not that if it's the same server. Could I suggest you remove the 2 second timeout you've set?
It defaults to 15sec, and I can't see that setting it to 2sec serves any useful purpose other than to potentially cause problems and error messages like the one you are getting.
Thanks I completely missed that. 2 seconds is not a lot, especially on the first request because you rely on the name servers responding in time, followed by the time to open a socket on a potentially busy server.
I apologise if I seem a bit vacant lately with respect to support requests. I move out to Australia in just under two weeks and I'm bogged down with work I have to get finished I appreciate the contributions of other members on this forum