Problem with fetching mail using TMail in Ruby on Rails

Posted by Shreyas Satish on Stack Overflow See other posts from Stack Overflow or by Shreyas Satish
Published on 2010-04-23T13:54:55Z Indexed on 2010/05/01 19:07 UTC
Read the original article Hit count: 210

Filed under:
|

While fetching email, TMail appears to parse the email body twice,when I use this code.All the other parameters are fine(from_email,email_subject). Any ideas?

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

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about tmail