Configure Rails Application to Retrieve All Email Messages from Inbox

I am using the following code to retrieve emails from my Gmail inbox.

def get_mail
  Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)  
  Net::POP3.start('pop.gmail.com', 995, "uname","pass") do |pop|  
  unless pop.mails.empty?
       pop.each_mail do |mail|  
        email = TMail::Mail.parse(mail.pop)
        email_obj=EmailedQueries.new
        email_obj.save_email(email.from,email.subject,email.body_html)        
        end 
    end
 end   
end

      

This works great, but it only fetches new emails from the inbox. Instead, I need a separate function that will fetch ALL emails from the Inbox. This feature will rarely be used. I will not receive all emails all the time. Only when needed.

Thanks!

+2


a source to share


1 answer


You need to configure your POP settings in GMail.Enable "Pop for All Mail" and you're good to go!



+1


a source







All Articles