Configure Rails app to retrieve ALL emails from inbox
- by Kartik Rao
I'm 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 just fine, but it retrieves only new mails from the inbox. Instead, I want a seperate function that will retrieve ALL emails from the inbox. This function will be used rarely. I wont be retrieving all mails all the time. Only when necessary.
Thanks!