Rails - Parsing an e-mail message only for reply, not for old subject?

I installed an application to receive incoming email messages through a message from a service. The controller that receives the messages looks something like this:

    class IncomingMailsController < ApplicationController    
      require 'mail'
      skip_before_filter :verify_authenticity_token

      def create
        message = Mail.new(params[:message])
        message_plain = (params[:plain])
        Rails.logger.info   'message2.plain:'
        Rails.logger.info   message2

        render :text => 'success', :status => 200 # a status of 404 would reject the mail
      end
    end

It successfully delivers the entire email, replies, forwards the history, etc. The problem is that I would like to receive only the text of the answer.

I am currently getting:

That not a bad idea. Lets try that out.

On Nov 17, 2010, at 4:18 PM, XXXXX @ XXXXXXXX wrote:
> There a new reply:

And I would like to know how rails devs only get the answer:

That not a bad idea. Lets try that out.

Ideas? Thanks

+5
source share
3 answers

, , .

teambox , , - :

def strip_responses(body)
# For GMail. Matches "On 19 August 2010 13:48, User <proj+conversation+22245@app.teambox.com<proj%2Bconversation%2B22245@app.teambox.com>> wrote:"
body.strip.
  gsub(/\n[^\r\n]*\d{2,4}.*\+.*\d@app.teambox.com.*:.*\z/m, '').
  split("---------separator---------").first.
  split("<div class='email'").first.
  strip
end
+3

, Github: Email Parser

0

extended_email_reply_parser, github email_reply_parser.

Gemfile:

# Gemfile
gem 'extended_email_reply_parser'

:

message_plain = ExtendedEmailReplyParser.parse message

:

class IncomingMailsController < ApplicationController    
  skip_before_filter :verify_authenticity_token

  def create
    message = Mail.new(params[:message])
    message_plain = ExtendedEmailReplyParser.parse(message)

    render :text => 'success', :status => 200 # a status of 404 would reject the mail
  end
end

email_reply_parser vs. extended_email_reply_parser

email_reply_parser github. , , .

extended_email_reply_parser - github. , . , , , , .

0

All Articles