Description
This article describes how to set up the MPMail mail flow rules using powershell
Requirements
- A global admin account in the Microsoft 365 tenancy
The Process
- Open powershell and connect to exchange online with the following command: Connect-ExchangeOnline
- Enter global admin credentials
- Once authenticated and connected, enter the following command to create the MPMail Inbound rule: New-TransportRule "MPMail Inbound Rule" -ExceptIfFromScope InOrganization -RejectMessageEnhancedStatusCode 5.7.1 -RejectMessageReasonText "Email bypassed MXRecords" -ExceptIfSenderIpRanges 94.100.128.0/20,185.140.204.0/22,173.45.18.0/24,83.246.65.0/24,81.20.94.0/24,52.62.114.130,52.62.125.178,35.174.145.124,15.222.110.90,52.212.19.177 -ExceptIfMessageTypeMatches Calendaring
- Enter this command to create the rule that bypasses Microsoft Spam Filtering: New-TransportRule "Bypass Spam Filtering" -SentToScope InOrganization -SetSCL -1
- You can also create the connector but it will still need to be validated via the Exchange Admin Center. To create it, use this command: New-OutboundConnector -Name "MPMail Outbound" -Comment "Send all external outbound email through MPMail SmartHost" -Enabled $true -RecipientDomains * -SmartHosts <domain>.outbound.anz.mpmailmx.com -TlsSettings EncryptionOnly -UseMXRecord $false