Public/TenantConfiguration/New-SpamfilterConnector.ps1




function New-SpamfilterConnector() {
    param(
        [Parameter(Mandatory)]
        [string]$TenantId
        )
        Connect-CustomerExchange -CustomerTenantId $TenantId
        
        try {
            $TransportRuleName = "Bypass Spamfilter spamfilter.io"
            $WhiteListedIPs = @(
                "46.36.212.32/27",
                "89.188.78.64/27",
                "94.231.106.10/32",
                "94.231.106.11/32",
                "94.231.106.12/32",
                "94.231.106.13/32",
                "94.231.106.14/32"
            )
            $SpamConfidenceLevel = "-1"
            $Mode = "Enforce"
            Write-Host "Creating transport rule..." -ForegroundColor Cyan
            New-TransportRule -Name $TransportRuleName -SenderIpRanges $WhiteListedIPs -SetSCL $SpamConfidenceLevel -Mode $Mode
            Write-Host "Creating inbound connector..." -ForegroundColor Cyan
            New-InboundConnector -SenderIPAddresses $WhiteListedIPs -SenderDomains * -RequireTls $false -Name "Spamfilter.io Inbound"
            Write-Host "Completed creating spamfilter.io Exchange Connector." -ForegroundColor Green
        } catch {
            Write-Error "Failed to create spamfilter.io Exchange Connector: $_"
        }
}