[Mimedefang] defang_mime = 1 in spamassassin.cf with MIMEdefang

Mike Batchelor mikebat at tmcs.net
Thu Apr 4 14:40:12 EST 2002


--On Thursday, April 04, 2002 9:28 AM -0800 Mike Batchelor 
<mikebat at tmcs.net> wrote:

> --On Wednesday, April 03, 2002 3:47 PM -0500 "David F. Skoll"
> <dfs at roaringpenguin.com> wrote:
>
>> If you want to convert text/html to text/plain, you have to write
>> a filter rule to do it.  See for example the thread at:
>>
>>
> http://lists.roaringpenguin.com/pipermail/mimedefang/2002-March/000646.ht
> ml

I'm having a problem with this approach.  It isn't changing the 
Content-Type.

Here's how I have it set up:

I do the Spamassassin checks in filter_begin(), straight from the 
MIMEdefang Tips page on RoaringPenguin, with slight changes:

sub filter_begin {
  # drop messages with suspicious characters
  if ($SuspiciousCharsInHeaders || $SuspiciousCharsInBody) {
    ..... code from tips page ....
  }

  # Spamassasin checks
  $foundSpam = "no";
  if ((-s "./INPUTMSG") <= (50 * 1024)) {
    my($hits, $req, $names, $report) = spam_assassin_check();
    if ($hits >= $req) {
      action_add_header("X-Spam-Detect", "HIGH");
      action_add_header("X-Spam-Status", "Yes, hits=$hits required=$req");
      $foundSpam = "yes";
    } else {
      action_add_header("X-Spam-Status", "No, hits=$hits required=$req");
    }
    action_add_header("X-Spam-Report", "$report");
  }
}

Then in filter(), after the code from the Tips page that strips out 
dangerous attachments, I add these statements:

  if ($foundSpam eq "yes") {
    if ($type eq "text/html") {
      $entity->head->mime_attr("content-type" => "text/plain");
    }
  }
  return_action_accept();


And then filter() ends.  Problem is, text/html spam still comes through as 
text/html.  It is not converted to text/plain as Spamassassin alone can do.

What am I missing?  It's probably a dumb perl mistake.  I'm not very good 
at perl yet.  I am wondering if the scope of my variable $foundSpam as set 
in filter_begin() isn't what I think it is, and the "yes" value is not seen 
inside filter().

---
"The avalanche has already begun. It is too late for the pebbles to vote."
 -- Kosh



More information about the MIMEDefang mailing list