PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jun 19, 2018 10:52 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Error using Gmail SMTP
PostPosted: Mon Mar 24, 2008 2:18 am 
Offline
Forum Newbie

Joined: Mon Mar 24, 2008 2:15 am
Posts: 11
I tried using gmail's smtp but it returns the following error:

Fatal error:
Uncaught Error of type [swift_connectionexception] with message [The SMTP connection failed to start [smtp.gmail.com:2]: fsockopen returned Error Number 110 and Error String 'Connection timed out']
@0 swift::swift() in /home/philippi/public_html/email-sender.php on line 5
@1 swift::connect() in /home/philippi/public_html/swift_mailer/Swift.php on line 109

in /home/philippi/public_html/swift_mailer/Swift/Errors.php on line 99

This is the code:
$swift =& new Swift(new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS));


Top
 Profile  
 
PostPosted: Mon Mar 24, 2008 2:26 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
Copied from my e-mail response to you:

I wrote:
Hi Jebb,

It sounds as though your host have firewalled off that port (465). Two hosts I know block connections are 1and1 and GoDaddy if you're on their shared hosting plans. Many other hosts do too. If Swift cannot make connections to remote servers then there's not much it can do where SMTP is concerned. The NativeMail and Sendmail connections may still work however.

Best Regards,

Chris


Top
 Profile  
 
PostPosted: Mon Mar 24, 2008 3:30 am 
Offline
Forum Newbie

Joined: Mon Mar 24, 2008 2:15 am
Posts: 11
this is the entire code I copied from swift's example:
<?php
require_once 'swift_mailer/Swift.php';
require_once 'swift_mailer/Swift/Connection/SMTP.php';

$swift =& new Swift(new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS));

$message =& new Swift_Message("My Subject", "My Body");

if ($swift->send($message, "jebb.domingo@hotmail.com", "jeboy.25th@gmail.com"))
{
echo "Message Sent";
}
else
{
echo "Message Sending Failed";
}
?>


it returns this message now:
Fatal error:
Uncaught Error of type [swift_connectionexception] with message [The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 0 and Error String 'Success']
@0 swift::swift() in /home/philippi/public_html/email-sender.php on line 5
@1 swift::connect() in /home/philippi/public_html/swift_mailer/Swift.php on line 109

in /home/philippi/public_html/swift_mailer/Swift/Errors.php on line 99


Top
 Profile  
 
PostPosted: Mon Mar 24, 2008 3:46 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
This is a known bug with some PHP 4 versions. An error has occurred but the error number and error string have not been correctly generated. I suspect the cause in this particular case will be a lack of TLS support in PHP. Unofortunately PHP4 does not have a way to verify whether TLS support was compiled with OpenSSL.

Who is your host out of curiosity? I ask because you're the first person to post PHP4 code in a while and PHP4 is deprecated so hosts shouldn't really still be using it.


Top
 Profile  
 
PostPosted: Mon Mar 24, 2008 6:19 pm 
Offline
Forum Newbie

Joined: Mon Mar 24, 2008 2:15 am
Posts: 11
Actually we run our own hosting provided by itassociates in australia. One website that is hosted by our whm has a very simple newsletter system, its just a simple and manual sending of email to subscriber, the problem is with a subscriber using hotmail cannot receive our email. we tried to use gmail's smtp to test if hotmail blocks our ip/dns. Regarding the version of swift we used, we run PHP5 but when we try Swift version for PHP5, it generates an error with constants in Swift.php, its says something like the type of declaration of constant doesn't support by the PHP parser. I will try to run that swift version again and post the error message.


Top
 Profile  
 
PostPosted: Mon Mar 24, 2008 6:30 pm 
Offline
Forum Newbie

Joined: Mon Mar 24, 2008 2:15 am
Posts: 11
This is the error message when I try Swift 3.3.2 for PHP5:

Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/philippi/public_html/swift_mailer5/Swift.php on line 36


Top
 Profile  
 
PostPosted: Mon Mar 24, 2008 6:54 pm 
Offline
Forum Newbie

Joined: Mon Mar 24, 2008 2:15 am
Posts: 11
Sorry I mistakenly identified the site's php version, it runs on PHP4. Sorry for misinformation


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group