Help us understand the problem. What is going on with this article?

Rubyのimapでyahooメール受信

More than 5 years have passed since last update.

すこしはまったのでメモ

Yahooメールのサーバー設定
受信メール(IMAP)サーバー imap.mail.yahoo.co.jp
受信メール(IMAP)通信方法 SSL
受信メール(IMAP)ポート番号 993
require 'net/imap'
require 'io/console'

$stderr.print 'user : '; user = gets.chomp
$stderr.print 'pass : '; pass = STDIN.noecho(&:gets).chomp

imap = Net::IMAP.new('imap.mail.yahoo.co.jp', 993, true, 'cacert.pem')

imap.authenticate('LOGIN', user, pass)
imap.examine('INBOX')

msgids = imap.search(["ALL"]).last #最新一件を取得
imap.fetch(msgids, %w(BODY[HEADER] BODY[TEXT])).each do |mail|
    puts mail.attr["BODY[HEADER]"]
    puts mail.attr["BODY[TEXT]"]
end

cacert.pemという証明書が必要。自分は http://curl.haxx.se/ca/cacert.pem から持ってきた。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away