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

Tom Lahti toml at bitstatement.net
Fri Apr 3 15:16:17 EDT 2009

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.

Has anyone else done anything like this already, or am I venturing into
uncharted waters here?  Does my plan sound decent, or am I crazy for even
thinking of it?

-- ============================
   Tom Lahti
   BIT Statement LLC

   (425)251-0833 x 117
-- ============================

More information about the rt-users mailing list