Task given: An email is stored, byte for byte, in one or more chunks (of fixed length) in a database. This mail is to be retrieved from that database and it's contents shall be displayed to the user.
I have no problem wrapping the legacy database in an ActiveRecord model, concatenating the stored chunks and so on. What I don't really know is where to start on the MIME parsing part. I thought about something like perhaps having a dedicated EMail class which I can initialize with the data stored within the database and that class would allow me to see what MIME parts the mail consist of and allowed me to display, e.g., the text/*
parts of it.
Now it seems that ActionMailer is able to parse incoming mails, but the doucmentation on receiving mails seems to be rather, erm, "sparse" and it just mentions receiving mails from STDIN.
How can I parse and display a MIME mail (or parts of it) in Rails, given that I can provide it's contents as a single string, variable, query result or soemthing like that?