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? Thanks in advance! --David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2009-Mar-18 18:43 UTC
Re: Extracting just the text of an ActionMailer receive e-mail
> 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Starr Horne
2009-Mar-19 14:38 UTC
Re: Extracting just the text of an ActionMailer receive e-mail
> 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. -- Starr Horne Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David
2009-Mar-19 20:13 UTC
Re: Extracting just the text of an ActionMailer receive e-mail
Philip & Starr, thanks for the suggestions. I appreciate the response. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David
2009-Mar-20 02:44 UTC
Re: Extracting just the text of an ActionMailer receive e-mail
I ended up using the MMS2R library and it was quite simple and did exactly what I needed. MMS2R is here: http://rubyforge.org/projects/mms2r/ I installed it using the gem command: sudo gem install mms2r Added this to the top of my ActionMailer file: require ''mms2r'' Then all I needed to do to get the text only version of the body of an incoming message was this: (inside my receive(mail) handler) mms = MMS2R::Media.new(mail) plain_body_text = mms.body 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. --David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---