Search code examples
ruby-on-railsrubygmailmailman

How to process an email thread with mailman


If the person replying to a "ticket" is using a mail client such as gmail that reply will show a whole conversation thread when I do @message.body.decoded rather than the text that they typed.

Is there a way to extract just that portion of text?


Solution

  • Generally, the existing replies are formatted with a preceding >. One option is to extract lines that do not begin with that character.

    So you look at the email as plain-text, you can extract it. Here is an example:

    --f46d0basically0a0unique0id # Marks the start of content for this email
    Content-Type: text/plain; charset=ISO-8859-1
    
    Hello foo,
    
    This is a message.
    
    Regards,
    Bar
    
    >
    > Original response
    > is quoted like this
    > What in included here 
    > depends on mail client
    >
    
    
    --f46d0basically0a0unique0id # Marks the end of content for this email