Swift with gmail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Swift with gmail

Post by shiznatix »

Im trying out this handy dandy switft stuff but I can't get it to work with gmail. it says that i need to enable somthing in my php.ini file but i have no idea what. here is the error I get:
fsockopen() [function.fsockopen]: unable to connect to tls://smtp.gmail.com:465 (Unable to find the socket transport "tls" - did you forget to enable it when you configured PHP?)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

PHP needs to be compiled with OpenSSL support for TLS to work. It also doesn't exists *at all* in PHP < 4.3.0
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

ok now when i try to connect it just times out after like 15 seconds. it's like this:

Code: Select all

//this works
$thing = file_get_contents('http://www.google.com');
dump($thing);

//this times out
$mailer = $this->LoadExtension('Swift', array('ConnectionType' => 'gMail'));
my loading of swift:

Code: Select all

require('./Extensions/Swift/Swift.php');
require('./Extensions/Swift/Swift/Swift_SMTP_Connection.php');

$swift = new Swift(new Swift_SMTP_Connection('smtp.gmail.com', SWIFT_SECURE_PORT, SWIFT_TLS));
the error:
fsockopen() [function.fsockopen]: unable to connect to tls://smtp.gmail.com:465 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Can you show me a phpinfo() output? :)
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

just sent you a pm of the html of phpinfo() because i don't have a website right now and everything is being done locally.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Says TLS is a registered stream... hmm.. Not too sure on this :? I've had one other developer contact me having difficulty getting TLS to work on windows and he said something about needing the static binaries for OpenSSL for it to work but I'm not 100% on that. The odd thing is that the error you're getting seems to suggest it's Gmail that's not responding but I doubt that.

Not sure it makes much difference but Gmail is using the Thawte Root Ca certificate... perhaps OpenSSL for windows does not include that cert so you may need to include it yourself.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

where do i get this certificate and how do i include it myself? i don't know very much about certificates and whatnot.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

shiznatix wrote:where do i get this certificate and how do i include it myself? i don't know very much about certificates and whatnot.
I'll PM you about that.
Post Reply