Fetching email using Ruby on Rails

后端 未结 2 1596
醉梦人生
醉梦人生 2021-02-04 18:57

I need to fetch email from my gmail account using RoR.

require \'net/pop\'
Net::POP3.start(\'pop.gmail.com\', 995, username, password) do |pop|  
    if pop.mai         


        
相关标签:
2条回答
  • 2021-02-04 19:26

    You need to use SSL

    0 讨论(0)
  • 2021-02-04 19:43

    Try this one:

    require 'net/pop'
    Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)  
    Net::POP3.start('pop.gmail.com', 995, username, password) do |pop|  
      if pop.mails.empty?  
        puts 'No mails.'  
      else  
        pop.each_mail do |mail|  
          p mail.header  
          p mail.pop  
        end  
      end  
    end  
    
    0 讨论(0)
提交回复
热议问题