Ruby IMAP login error exception

2019-04-13 01:27发布

问题:

With my Ruby script:

imap = Net::IMAP.new('imap.gmail.com')
imap.login("some_email@host.com", password)

I get the following exception:

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

What's wrong?

回答1:

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("user@host.com", "password")


标签: ruby imap