On Mon, 2018-06-18 at 06:13 -0600, @lbutlr wrote: > I have a script that runs when a mail is moved out of the Junk folder > to pass the mail through sa-learn --ham, but it doesn’t removed the > subject tagging (Spam: 05.5) nor does it remove the X-Spam-Flag > header. > > What would I need to do in the script to remove the SA tags on > messages that are processed by this script? > I normally use an awk script for this sort of job because they are short, easy to write and run fast.
Here's one I use to remove SA headers from the messages I keep as an SA test corpus. Its part of a larger, site-specific, shell script. Much of its apparent complexity is because its capable of deleting multi-line SA headers and because it recognises the blank line following the headers and switches into a pure copy mode at that point. ==================================================================== #!/bin/bash # First argument of this shell script is the file containing the # message to be cleaned # Second argument is the file the cleaned message is to be written to # awk ' BEGIN { act = "copy"; body = "no"; } /^[A-Za-z]/ { act = "copy" } /^X-Spam/ { act = "skip" } /^$/ { body = "yes"; } { if (act == "copy" || body == "yes") { print } } ' <$1 >$2 ==================================================================== If you don't know awk, and the mere fact of you asking this question suggests you don't, I strongly suggest you get hold of the O'Reilly "Sed & Awk" book and learn how to write awk scripts because you're likely to find all sorts of uses for awk once you know it. Martin