GMail Issue

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
bpirtle
Forum Newbie
Posts: 2
Joined: Tue Apr 17, 2007 4:19 am

GMail Issue

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
bpirtle
Forum Newbie
Posts: 2
Joined: Tue Apr 17, 2007 4:19 am

Post by bpirtle »

It's a shared host...is there any way around this or do I need to simply use their mail server?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
Post Reply