[rt-users] RT-Mailgate hack to remove quoted replies

Adam Clarke adam.clarke at strategicdata.com.au
Sat Apr 4 04:24:26 EDT 2009

On 04/04/2009, at 6:16 AM, Tom Lahti wrote:

> I am having an awful time with getting users to remove quoted text  
> from
> replies.  I've begun looking at rt-mailgate code to figure a way to  
> remove
> the "---- Original Message ----" and below it that Outlook creates  
> when you
> hit reply.
> the write_down_message() function seems to either create a temp file  
> or use
> memory to take the message from STDIN.  I thought about stripping it  
> down
> during reading from STDIN but its being read in binmode 8k at a  
> time, so the
> "---- Original Message ----" might be broken across chunks.  So that  
> won't work.
> After write_down_message(), I could simply regex it into oblivion --  
> if its
> in memory.  If its in the temp file... it doesn't seem like a scalable
> solution to read the temp file and re-write it.  We've already  
> written the
> message to the temp file once.
> What I'd like to do is go back to write_down_message() and look for  
> the key
> line, and do some sneaky read-ahead of a few bytes into the next  
> buffer if
> the end of the buffer _could_ be a broken "Original Message" line,  
> and then
> seek back to the beginning of that chunk if it isn't.
> Finally,  I suspect that Outlook puts attachments after the body, in  
> which
> case an email reply that contains attachments would get the  
> attachments
> dropped unless I keep reading for a MIME boundary, in which case I  
> have to
> know what the boundary is in the first place, which means parsing  
> the header.

I don't think it is crazy to want to solve the problem but I suspect  
you would regret the method by which you are considering solving it.

I haven't tried this, but if I were going to I would do it on  
retrieval and display rather than by altering the message on the way  
in. That way when it turns out your parsing is imperfect you haven't  
damaged the original and you might even offer the user a way to  
recover by peeking at the original.

Adam Clarke

More information about the rt-users mailing list