Unfortunately my Googling skills have failed me. I'm looking for
something that will help me quickly parse through the body of a
message received by my ActionMailer based code. Here's the issue: If
someone sends an e-mail to an address that I am reading the body of
the message will often contain two parts: a text version of the
message and/or an HTML version of the message.
I know there are MIME parsing and multi-part issues here, I'm just
looking for a super simple routine that will grab a single text based
version of the message body so that I can store it in my DB. Any
hints, recommendations or links I should be following?
Unfortunately my Googling skills have failed me. I'm looking for
something that will help me quickly parse through the body of a
message received by my ActionMailer based code. Here's the issue: If
someone sends an e-mail to an address that I am reading the body of
the message will often contain two parts: a text version of the
message and/or an HTML version of the message.
I know there are MIME parsing and multi-part issues here, I'm just
looking for a super simple routine that will grab a single text based
version of the message body so that I can store it in my DB. Any
hints, recommendations or links I should be following?
I haven't done it in Ruby yet, but my advice would be to go find that MIME parsing library and use it.
Then it becomes a simple matter of looping through the body parts until you find one that is plain text.
Unfortunately my Googling skills have failed me. I'm looking for
something that will help me quickly parse through the body of a
message received by my ActionMailer based code. Here's the issue: If
someone sends an e-mail to an address that I am reading the body of
the message will often contain two parts: a text version of the
message and/or an HTML version of the message.s>
I know there are MIME parsing and multi-part issues here, I'm just
looking for a super simple routine that will grab a single text based
version of the message body so that I can store it in my DB. Any
hints, recommendations or links I should be following?
Take a look at MMS2R. While it was written to handle MMS message, it's good at pulling apart any kind of email.
The only catch I encountered was that I wanted to extract MMS2R into
my vendor/gems directory but I really had a difficult time finding all
of the dependencies. I ended up punting and simply installing the gem
on my server as well, though I would rather not do that.
I hope this helps anyone searching for this kind of capability.