0

I am looking for an easy way to parse an IMAP struct that I have read from an exiting email account. Ideally if you could point me to an existing gem that handles imap emails. Everything I find is extremely old.

My app fetches email from an existing, external imap account. I am able to read the email and retrieve it and even to parse it and extract most of the information I want. However, I am not able to extract the HTML or text body parts easily. Overall, parsing the struct that is returned by the net/imap library is difficult to handle.

All the help articles that I can find on the topic seem VERY old and existing gems have not been updated in many years.

Is there not an easy way, a gem or built in library to handle imap objects? I am also open t rewriting my app to do things easier. My code below is workig fine. The envelopes struct that I receive back is just really awful to work with.

      connection = Net::IMAP.new(server.inbound_server, server.inbound_port, server.inbound_encryption)
      connection.login(server.inbound_user, server.inbound_password)

      connection.examine("INBOX")
      uid_list = connection.search(["FROM", search_term])
      envelopes = connection.fetch(uid_list, "ENVELOPE")
Boenne
  • 605
  • 4
  • 17
  • Seems like this thread could be relevant to you: https://stackoverflow.com/questions/1101101/how-to-read-the-body-text-of-an-email-using-rubys-net-imap-library – Unixmonkey Apr 09 '20 at 19:49
  • Could you be a little more detailed in one way or another? Right now it looks like yet another request to write code for you or provide a tutorial, and I think that may be unfair. So please edit to get closer to a concrete problem. Thanks. – arnt Apr 09 '20 at 19:53
  • hey @arnt. I am looking for a gem that does the trick for me. I have no problem writing the code but manually processing an imap response is just not very elegant. I was hoping someone could recommend an existing gem. I added the request to point me to a gem. I hope that makes it more clear. – Boenne Apr 09 '20 at 20:06
  • @Unixmonkey, I am aware of this thread but note, it is 10 years old! the TMail ge has not been maintained for 10yrs! I am not sure that's still safe or even compatible with rails 6. – Boenne Apr 09 '20 at 20:09
  • 1
    @Boenne The IMAP standard hasn't changed much in 10 years that I know of either, and I don't think this library depends on Rails in any way, so I don't think it'll be a problem. Just because code isn't frequently updated, doesn't mean it is bad. It could be that it solves the problem well and is stable. – Unixmonkey Apr 09 '20 at 21:02

0 Answers0