MDaemon and SecurityGateway are both using SpamAssassin. You can copy any of the spamassassin configurations (stored in .cf files) from one server to the other, the whitelist (to) whitelist (from) found in MDaemon under Security / Spam Filter / Spam Filter are included in this. The whitelist (no filtering) is not included.
To copy the whitelist (to) and whitelist (from), On the MDaemon server go to the MDaemon\SpamAssassin\Rules directory and copy the 80_whitelist_from.cf, and 80_whitelist_to.cf files to the Program Files\MDaemon Technologies\SecurityGateway\SpamAssassin\rules on the SecurityGateway server.
If you'd like to adjust the scores being assigned to whitelisted edit the local.cf and add the following (if they already exist just edit what is there.)
score USER_IN_WHITELIST -100.0
score USER_IN_WHITELIST_TO -100.0
Save the files and restart SGSpamD.exe.
Here is a script that will extract contacts from MD and import them into the whitelist in SG. It must be ran on the MDaemon server. You'll want to adjust the $Global:SGXMLRPCURL, $UserName, and $Password variables for your environment. The script is looking at the whitelist contact folder for each user. If you'd like to import addresses from a different contact list you'll need to adjust the $MRKPath appropriately. Also, I highly reccomend backing up all contact lists in MDaemon and your SecurityGateway server before running the script, and please run tests to make sure the script is going to do what you want it to before running it on your live servers.
################################################################################################################################
################################################################################################################################
## SG Import MD User Whitelist v 1.0.0 ##
## February 10, 2022 ##
## Copyright MDaemon Technologies 2022 ##
## This script is designed to retrieve contact email addresses from the user's whitelist and import them into the user's ##
## SG Whitelist This script is only to be used with MDaemon Technologies products. The use of this script for any other ##
## purpose or with any other products is not allowed. ##
## ##
## 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. ##
## ##
################################################################################################################################
################################################################################################################################
$MRKPath = "C:\MDaemon\Users\*\*\WhiteList.IMAP\AddrBook.mrk"
$Global:SGXMLRPCURL = "http://127.0.0.1:4000/SecurityGateway.dll?view=xmlrpc"
$Username = "User"
$Password = "Password"
$Comment = "Imported from MDaemon"
Import-Module SGAPI
$OpenSession = Open-SGSession -URL $Global:SGXMLRPCURL -UserName $UserName -Password $Password
if($OpenSession -eq 0){
ForEach($File in Get-ChildItem -Path $MRKPath -Recurse -Filter "AddrBook.Mrk"){
$UserDomain = split-path -Path (split-path -Path (split-path -Path (Split-Path -Path $File.FullName -Parent) -Parent) -Parent) -Leaf
$UserMailbox = split-path -Path (split-path -Path (Split-Path -Path $File.FullName -Parent) -Parent) -Leaf
$UserEmail = $UserMailbox + "@" + $UserDomain
$UserExists = $false
$SGUsers = Get-SGUsers -Domain $UserDomain
ForEach($User in $SGUsers){
if($User.MailBox -eq $UserMailbox){
$UserExists = $true
#Write-Host $User.Mailbox "matches" $userMailbox
} else {
#Write-Host $User.Mailbox "did not match" $UserMailbox
}
}
if($UserExists){
Write-Host "$UserEmail was found in SG. Proceeding..."
[xml]$WhiteList = Get-Content $File.FullName
$Emails = $WhiteList.SelectNodes('//addressBook/contact/email/text()').Value
ForEach($Email in $Emails){
if($Email){
$Result = Add-SGToUserWhitelist -EmailToAdd $Email -UserEmail $UserEmail -Comment $Comment
if($Result -eq 0){
Write-Host "Adding $Email to the $UserEmail User Whitelist"
} else {
Write-Host "there was an error adding $Email to the $UserEmail whitelist"
}
} else {
Write-Host "A contact was found but the email field was empty... Ignoring."
}
}
} else {
Write-Host "$UserEmail was not found in SG. Skipping..."
}
}
$CloseSession = Close-SGSession
if($CloseSession -eq 0){
Write-Host "The SG connection was successfully closed."
} else {
Write-Host "There was a problem closing the connection to SecurityGateway"
Write-Host $CloseSession
}
} else {
Write-Host "There was a problem opening the connection to SecurityGateway"
Write-Host $OpenSession
}