Fetching email using Ruby on Rails

后端 未结 2 1598
醉梦人生
醉梦人生 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: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  
    

提交回复
热议问题