Content filter question | MDaemon Technologies, Ltd.

Content filter question


  • Hello, I am having no luck trapping all messages sent to a mailing list for content filtering. The current rule catches messages with the mailing list address in the TO header, the CC header and the BCC header. Somehow, messages are getting past that rule and cannot see how they are addressing the list without using one of those headers.

    The messages that get through without triggering the rules have "X-Rcpt-To" and "X-MDRcpt-To" headers added to them, but I cannot seem to get those headers to trigger a user defined header rule. It seems that none of the "X" or "X-MD" headers will trigger the rule.

    I simply need to trap ALL messages sent to the mailing list address for content filter processing. Is there a better way?

     

    Thanks,

    Dan

     



  • Hi Dan,

    Do you have the setting "Apply content & spam filters to list mail before cracking individual copies" enabled or disabled? This is under Settings in the Mailing List Manager area for the list you're working with.

    This is from the help file: When the Deliver list mail to each member individually option is chosen on the Routing screen of the mailing list editor, enabling this control will cause the content filter rules and spam filter to be applied to list messages before they are copied and distributed to list members.

    If that doesn't help, can you post a copy of the content filter rule you're using, and give an example of a message it's not catching?


  • The first thing to check is if the content filter is set to process list mail before or after the list mail is cracked. You can check the setting by going to Setup / Mailing List Manager / Mailing List Settings.  If the box for "Appy Content & Spam filters to list mail before cracking individual copies is checked, then the processing happens while the message is still in the Inbound Queue and most of the message headers you are expecting to be present are not yet added to the message.  Based on what you are describing I believe you have this box enabled.  And there is no way that I have found to catch 100% of messages addressed to a specific list when its configured like this.

    If you uncheck the box so that the content filter is applied after the fact, you can catch all list mail by simply checking the X-MDMailing-List: header for the email address of the mailing list.  If your content filter rule is doing something like placing the messages in the bad queue, you will end up with mulitple copies of the message in the bad queue.  You could end up with as many as 1 message for each recipient of the mailing list.


  • Leigh & Arron, I DO have both the "Appy Content & Spam filters to list mail before cracking individual copies" and "Deliver list mail to each member individually" checked. When I uncheck "Appy Content & Spam filters to list mail before cracking individual copies", I end up with multiple copies of the same message being processed, as Arron stated.. Unfortunately, that is counter productive to what I am trying to accomplish.

    Is there no other rule that I can use to process ALL messages sent to a mailing list?

     

    Thanks,

    Dan

     


  • What specifically are you trying to accomplish?


  • Arron, I want to filter the messages that contain words from a file and move them to a public folder.

     

    Dan


  • I messed around with this a bit tonight and I think I have something that will work for you.   I ended up with 2 content filter rules and a powershell script...  

    Create rules similar to the following:

    [Rule007]
    RuleName=List Grabber
    Enable=Yes
    ThisRuleCondition=Any
    ProcessQueue=BOTH
    Condition01=body|all message|AND|
    Action01=run a program|"-1,0,0","C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File c:\temp\FilterlistMail.ps1 $MESSAGEFILENAME$"
    [Rule008]
    RuleName=ListChecker
    Enable=Yes
    ThisRuleCondition=All
    ProcessQueue=BOTH
    Condition01=body|process exit code|AND|=|1|
    Action01=move to public folders|"test.com/Messages"

    You'll want to add a condition to the ListChecker rule to look for words from a file in the message body.  

    Then copy the script below and put it into a PS1 file.  The ListGraber rule is expecting the script to be at c:\temp\FilterlistMail.ps1, you can put it anywhere you'd like, the path used in the rule needs to be the same as where you put the file on disk. Then edit the script and change the $ListEmail, $LogPath, and $InboundPath variables to match your server.  The $InboundPath variable needs to have the \* on the end of it.

    If you don't want logging, comment out the Start-Transcript and Stop-Transcript lines by adding a # at the beginning of the line.  

    ## MDaemon Technologies offers no warranty, provides no support, and is not responsible for any damages that may be arise     ##
    ## from the use of this script. Use at your own risk.                                                                         ##
    param(
        [string]$MSGFileName = "C:\MDaemon\Queues\Inbound\md5001000000432.msg"
    )
    
    $REGEX = '(\d{1,3}\=)(.*)(\s)(.*\s)'
    $ListEmail = "listname@domain.com"
    $LogPath = "c:\temp\FilterListMail.log"
    $InboundPath = "c:\mdaemon\queues\inbound\*"
    
    Start-Transcript $LogPath
    Write-Host "MSGFileName: $MSGFileName"
    
    if($MSGFileName -like $InboundPath){
        $CTLFileName = $MSGFileName.Replace(".msg",".ctl")
    
        Write-Host "CTLFileName: $CTLFileName"
        
        Get-Content $CTLFileName | Select-String -pattern $REGEX | ForEach-Object {
    
            $Recipient = $_.matches.groups[2].value.Trim()
            Write-Host "Recipient: $Recipient"
            if($Recipient -like $ListEmail){
                Write-Host "Message found to $ListEmail"
                Stop-Transcript
                Exit 1
            }
        }
    } 
    
    Stop-Transcript
    Exit 0

    If you haven't used Powershell on the MDaemon server, you'll need to set the execution policy.  The easiest way to do that is to add
    " -ExecutionPolicy bypass" to the end of the command line being called by the List Grabber content filter rule.

    This script has had very little testing so I'd highly reccomend that you test it before running it on your live system.

    ## MDaemon Technologies offers no warranty, provides no support, and is not responsible for any damages that may be arise     ##
    ## from the use of this script. Use at your own risk.                                                                         ## 

    Let me know if you have any questions.


  • @Arron 

    The script does not seem to run. I added the "-ExecutionPolicy bypass" to the end of the command per your suggestion, but no result or log file was created when I tested it.

    The command looks like this:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File N:\MDaemon\App\CF_FilterlistMail.ps1 $MESSAGEFILENAME$ -ExecutionPolicy bypass

     

    Dan


  • Do you have powershell installed on the machine?

    What version?  

    What OS?

    If you open Powershell ISE and run the PS1 file, what happens?  You should get an error about the file not existing similar to the following:

    Get-Content : Cannot find path 'C:\MDaemon\Queues\Inbound\md5001000000432.ctl' because it does not exist.

    If you change the command line to this does it work?

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy bypass -File N:\MDaemon\App\CF_FilterlistMail.ps1 $MESSAGEFILENAME$


  • @Arron 

    Seems to work now (using test messages sent to the list). I will need to let the spammers hit it for a couple of days to know for sure.

    I will post an update here in a few days. Thank you Arron, for the help and the cool PS voodoo.

     

    Dan


Please login to reply this topic!