[Mimedefang] Spamassassin Integration Question

Jeff Rife mimedefang at nabs.net
Fri Mar 23 13:41:07 EST 2007


On 23 Mar 2007 at 13:44, mimedefang-admin at spiresfamily.com wrote:

> However, I would still like to have the message scanned and I would like to 
> be notified if the message being sent out would be flagged as spam.  This 
> way if one of my users is sending spam I would know, or more likely if one 
> of my users is sending valid messages that would be tagged as spam I could 
> help correct they way they compose their message or work with them to get 
> their messages not tagged as spam.
> 
> Is this reasonable, or should I just ignore 'authenticated' senders sending 
> messages?

The only real change you'd have to make to the default supplied filter
is to add a check *after* the SpamAssassin call for what you want to 
do.

For example:

# Spam checks if SpamAssassin is installed
if ($Features{"SpamAssassin"})
  {
  if (-s "./INPUTMSG" < 100*1024)
    {
    # Only scan messages smaller than 100kB.  Larger messages
    # are extremely unlikely to be spam, and SpamAssassin is
    # dreadfully slow on very large messages.
    my($hits, $req, $names, $report) = spam_assassin_check();
    my($score);
    if ($hits < 40)
      {
      $score = "*" x int($hits);
      }
    else
      {
      $score = "*" x 40;
      }

    # adding this "if/else" is the only change you should need
    if ($SendmailMacros{'auth_author'})
      {
      # You can put anything you want in the message, of course
      action_notify_administrator("$Sender sent spam with subject $Subject\n");
      }
    else
      {
      # We add a header which looks like this:
      # X-Spam-Score: 6.8 (******) NAME_OF_TEST,NAME_OF_TEST
      # The number of asterisks in parens is the integer part
      # of the spam score clamped to a maximum of 40.
      # MUA filters can easily be written to trigger on a
      # minimum number of asterisks...
      if ($hits >= $req)
        {
        action_change_header("X-Spam-Score", "$hits ($score) $names");
        md_graphdefang_log('spam', $hits, $RelayAddr);

        # If you find the SA report useful, add it, I guess...
        action_add_part($entity, "text/plain", "-suggest",
                        "$report\n",
                        "SpamAssassinReport.txt", "inline");
        }
      else
        {
        # Delete any existing X-Spam-Score header?
        action_delete_header("X-Spam-Score");
        }
      }
    }
  }
--
Jeff Rife | "I feel an intense ambivalence, some of which 
          |  doesn't border entirely on the negative." 
          |  
          |         -- Ned Dorsey, "Ned and Stacey" 




More information about the MIMEDefang mailing list