连接到Yahoo!来自Ruby的邮件 [英] Connecting to Yahoo! mail from Ruby
问题描述
我尝试连接到Yahoo!邮件!使用net / imap和net / pop的Ruby帐户。但是我随机得到错误EOFile(来自IMAP)或连接拒绝/重置连接(来自POP)。有没有人尝试连接到Yahoo!邮件并对此有一些经验?
I try to connect to mail Yahoo! account from Ruby using both net/imap and net/pop. But I randomly get error EOFile (from IMAP) or Connection Refused/Reset by peer (from POP). Has anybody tried to connect to Yahoo! Mail and had some experiences about it?
推荐答案
ruby的net / imap库中存在一个错误,该错误会在连接到Yahoo时暴露出来。
该修补程序很简单,并在此处进行了描述:
There's a bug in ruby's net/imap library that is exposed when connecting to Yahoo. The fix is straightforward and described here:
http://redmine.ruby-lang.org/issues/4509
基本上,编辑imap.rb并更改search_response方法来自:
Basically, edit imap.rb and change the inner loop of search_response method from:
token = lookahead
case token.symbol
when T_CRLF
break
when T_SPACE
shift_token
end
data.push(number)
至:
token = lookahead
case token.symbol
when T_CRLF
break
when T_SPACE
shift_token
else
data.push(number)
end
然后使用以下代码进行测试:
then test with the following code:
require 'net/imap'
Net::IMAP.debug = true
conn = Net::IMAP.new('imap.mail.yahoo.com', 143, false)
conn.instance_eval { send_command('ID ("GUID" "1")') }
conn.authenticate('LOGIN', ARGV[0], ARGV[1] )
conn.select("INBOX")
uids = conn.uid_search(['ALL'])
puts uids.join(',')
conn.logout
conn.disconnect
这篇关于连接到Yahoo!来自Ruby的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!