tags:

views:

28

answers:

1

Hi!

My Ruby script:

imap = Net::IMAP.new('imap.gmail.com')
imap.login("[email protected]", password)

I get exception

A connection attempt failed because
the connected party did not properly
respon after a period of time, or
established connection failed because
connected hos has failed to respond. -
connect(2)

What's wrong?

+1  A: 

You need to connect using SSL on port 993.

Therefore your code should be this:

imap = Net::IMAP.new('imap.gmail.com', 993, true)
imap.login("[email protected]", "password")
Ryan Bigg
I get exception:SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
Oksana
There is probably a mismatch in the certificate (e.g. cn on the cert is not the same as imap.gmail.com) or perhaps the certificate signer is not in your store. If you want to ignore SSL issues, try this: `imap = Net::IMAP.new('imap.gmail.com', 993, true, nil, false)`. Doc link: http://ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M000754
Brian
Thanks, it works!
Oksana
Brian