How can I rewrite e-mail subjects?

kemis

Well-Known Member
Feb 17, 2005
104
0
166
Georgetown, TX
How can I rewrite e-mail subjects?

To be clear, I am NOT asking how to customize SA's spam tag! :) Actually, I want to do somewhat of the opposite...

My work implements a pretty horrible setup of SpamAssassin. Therefore, I am currently fetching mail from my work's POP3 account into my own Cpanel setup where I run my own spam checking.

I want to be able to DELETE the ' *****SPAM***** ' tags that my work applies, since it tags a LOT of ham and gets real annoying to work with when replying to a customer, etc.

I assume this would involve some sort of regex or filter in the exim configuration, but being a newbie, I don't want to start poking around without guidance.

Any ideas?
Matt
 

kemis

Well-Known Member
Feb 17, 2005
104
0
166
Georgetown, TX
Thanks for the link, Chirpy. After looking it over (it's all very new to me), I've come up with the assumption that I need a filter that resembles:

Code:
if $header_subject: contains "*****SPAM*****"
then pipe "sed -e 's/*****SPAM*****//'"
endif
So, now I need to figure out several things:

1. Is sed really what I need to use in this situation?
2. Am I calling the sed command correctly?
3. How do I get the message to continue to its intended destination after the search & replace?

I found the following thread via Google that covers this exact topic, but it doesn't lead to a concise conclusion: http://www.exim.org/pipermail/exim-users/Week-of-Mon-19990222/011453.html

I'll keep looking on my own, but if anyone wants to chime in with some ideas, I'd be very grateful. :D

-- Matt
 

Lyttek

Well-Known Member
Jan 2, 2004
772
4
168
Could this type of search/replace operation be done on the message AFTER it's been delivered to the appropriate directory on the server, but *before* the client has picked it up?

Can a trigger be setup that each time a new message comes in, the script could be run? Or ??
 

kemis

Well-Known Member
Feb 17, 2005
104
0
166
Georgetown, TX
I'm so close! I have the following filter that searches & replaces just fine. The only piece of the puzzle I'm now missing is how to actually get the output of the replace command back into exim for delivery! I tried a "deliver" statement, but that just delivers the original message, not the desired one.

Code:
if
 $header_subject: contains "*****SPAM***** "
then
 pipe "replace -s '*****SPAM***** ' ''"
endif
I've searched and searched! I honestly have no idea how to get the final message delivered. :(

Matt

P.S. -- Lyttek, I could set up a cron job to run the replace command on the appropriate mailboxes, but I wonder what would happen if/when a mail client attempts to download messages as the replace routine is running?