Page 1 of 1

GMail Issue

Posted: Tue Apr 17, 2007 4:23 am
by bpirtle
I used the following code to access my gmail account:

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("californiaswap@gmail.com");
$smtp->setPassword("*****");
 
$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, "bpirtle@gmail.com", "californiaswap@gmail.com")) echo "Sent";
else echo "Failed";
and the following error message appeared:

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 111 and Error String 'Connection refused']

My openssl is enabled on my php installation, so I am not sure why I can't connect. Any ideas?

Posted: Tue Apr 17, 2007 5:58 am
by Chris Corbyn
Something on your network is blocking the connection. Is it your server, or is it a shared host? Shared hosts quite commonly block most traffic that isn't for hosting websites.

Posted: Tue Apr 17, 2007 11:44 am
by bpirtle
It's a shared host...is there any way around this or do I need to simply use their mail server?

Posted: Tue Apr 17, 2007 12:06 pm
by Chris Corbyn
bpirtle wrote:It's a shared host...is there any way around this or do I need to simply use their mail server?
You will have to ask your host. I doubt you can circumvent their firewall rules though.