Rails Action Mailer - Strip footer information

327 Views Asked by At

Users can receive an email that is sent to a list of people. They are given a warning that they can unsubscribe from this listing at any time. The user can Reply All which will be sent back to the server and resent to everyone else. However, the footer still remains in their reply.

I am using ActionMailer to send the emails. They are multipart HTML emails.

What is the easiest way to strip this information? Ideally, I would want it so that any part of the reply message is not built into the message part.

enter image description here

Edit: More information

Think of this as a support ticketing. I would only want to create a new record containing the reply information instead of the chain of replies already in the ticket. For example, if the first email sent has "i need help!", the second reply would contain, "help with what?". The third reply would be "i dunno... i'm bored".

The ticket model would have three records:

  1. Record 1

    id = 1

    message = "i need help!"

  2. Record 2

    id = 2

    message = "help with what?"

  3. Record 3

    id = 3

    message = "i dunno... i'm bored"

edit

            doc = Nokogiri::HTML(message.html_part.body.decoded)
            doc.xpath("//blockquote").remove

I was able to strip the contents by using a as part of the message. However, the issue that I'm having now is below. Various email clients will add their own line of reply. For example, Outlook adds this.

enter image description here

Gmail adds this

enter image description here

Since these items will be included in the new stripping of the blockquote, how can i parse this part of the reply out as well to prevent having a garbled ticket record with junk data.

0

There are 0 best solutions below