Rails 连接到 POP3 邮箱,并检查是否有邮件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require 'net/pop'

mail_server = Net::POP3.new('mail.mailservernamehere.com')

begin
  mail_server.start('username','password')
  if mail_server.mails.empty?
    puts "No mails"
  else
    puts "#{mail_server.mails.length} mails waiting"
  end
rescue
  puts "Mail error"
end