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));
Error using Gmail SMTP
Moderators: Chris Corbyn, General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Error using Gmail SMTP
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
Re: Error using Gmail SMTP
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
<?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
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Error using Gmail SMTP
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.
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.
Re: Error using Gmail SMTP
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.
Re: Error using Gmail SMTP
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
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
Re: Error using Gmail SMTP
Sorry I mistakenly identified the site's php version, it runs on PHP4. Sorry for misinformation