This article describes how to set up the MPMail mail flow rules using powershell


  • A global admin account in the Microsoft 365 tenancy

The Process

  1. Open powershell and connect to exchange online with the following command: Connect-ExchangeOnline
  2. Enter global admin credentials
  3. 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,,,,,,,,, -ExceptIfMessageTypeMatches Calendaring
  4. Enter this command to create the rule that bypasses Microsoft Spam Filtering: New-TransportRule "Bypass Spam Filtering" -SentToScope InOrganization -SetSCL -1
  5. 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> -TlsSettings EncryptionOnly -UseMXRecord $false