SolidCP Windows 2016 support
09 - 11 - 2016
How to setup Lets Encrypt
30 - 03 - 2017

Move spam marked by Mailcleaner to Junk folder in Exchange

In this tutorial we will show you how to make Exchange automatically send Spam from MailCleaner directly to the users Junk folder in their Mailbox.

 

This rule is based on the MailCleaner header and not the subject to prevent any emails with spam in the subject being sent to the Junk Mail.

Automated Powershell Script

The below PowerShell script will create the rule for you with the correct value. It will need to be ran in the Exchange Management Shell.

$SCLJunkThreshold = (Get-OrganizationConfig).SCLJunkThreshold
$SCLJunkThreshold++
New-TransportRule -Name "Move Spam to Junk folder" -HeaderMatchesMessageHeader "X-MailCleaner-SpamCheck" -HeaderMatchesPatterns "spam" -SetSCL $SCLJunkThreshold -ExceptIfHeaderMatchesMessageHeader "X-MailCleaner-SpamCheck" -ExceptIfHeaderMatchesPatterns "not spam" -Priority 0

ECP version

First we need to check for the SCL Junk Threshold. This will tell us at what the highest number SCL will find a email as good. We will set this just above the threshold.

Run this Command: Get-OrganizationConfig | fl *SCL*

Exchange Transport rule

Create the transport rule

  1. Login to the Exchange ECP
  2. go to MailFlow -> Rules
  3. Click on the + and select Create a new rule
  4. In the New Rule window select More Options... at the bottom (This will allow the header checks to be visible)
  5. Enter a name such as: Move Spam to Junk folder
  6. In Apply this rule if.. select A message header... and then matches these text patterns
  7. Click Enter text... and enter X-MailCleaner-SpamCheck and click Ok
  8. Click Enter text patterns... and enter spam and click Ok
  9. select the Dropdown under Do the following... and select Modify the message properties... then Set the spam confidence level (SCL) to...
  10. You will then set to set this 1 above your SCLJunkThreshold we checked above. So in our example we would set this to 5
  11. Under Except If select Add Exception drop the Dropdown above the add exception button select A message header... and then matches these text patterns
  12. Click Enter text... and enter X-MailCleaner-SpamCheck and click Ok
  13. Click Enter text patterns... and enter not spam and click Ok
  14. Set the Priority to 0 so it is the first rule
  15. Click Save

We would like to thank bluechip Computer AG who provided us with this guide.

Trevor Robinson
Trevor Robinson
- CTO of Key4ce.
- More then 10 years of experience with Linux and Unix.
- Open source enthusiast

Key4ce - IT Professionals :: https://www.key4ce.com

Leave a Reply