Configure Rails app to retrieve ALL emails from inbox
Posted
by Kartik Rao
on Stack Overflow
See other posts from Stack Overflow
or by Kartik Rao
Published on 2010-04-28T06:38:48Z
Indexed on
2010/04/28
6:43 UTC
Read the original article
Hit count: 397
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!
© Stack Overflow or respective owner