Skip to main content
Question

How to Lock Down Exchange Online Direct Send and Prevent Gateway Bypass 6 months ago

  • April 24, 2026
  • 2 replies
  • 42 views

eduseq87

What is the specific PowerShell command used to prevent external entities from sending emails to your tenant using your own domain names?

Why is it necessary to enable "Enhanced Filtering for Connectors" when you have already locked down your tenant to only accept mail from a third-party gateway?

If an organization enables RejectDirectSend $true but forgets to update their SPF record to include their legitimate third-party sending services, what is the likely impact on outbound mail delivery?

2 replies

kentphelps
Community Manager
Forum|alt.badge.img+12
  • Community Manager
  • April 27, 2026

Let me know if this community blog entry helps:Β Mind the Gap: How to Lock Down Exchange Online Direct Send and Prevent Gateway Bypass


razvanb
Staff
Forum|alt.badge.img
  • Staff
  • April 28, 2026

There is no one PowerShell command to block external entities from sending emails with your domain to your Exchange Online organization. It depends on how you have configured it. You should have SPF, DKIM and DMARC correctly configured. You should not have your own domains as allowed in any of the policies in Exchange Online Protection/Defender for Office 365. You can also create an Exchange Transport Rule which block emails coming from outside the organization and which have your own domain name.Β 

Even after locking down your tenant to only accept mail from a third-party gateway (like Mimecast or Proofpoint), Microsoft still needs to see the original source IP of the sender to perform its own security checks. When mail passes through a third-party gateway, the "last hop" IP seen by Exchange Online is that of the gateway, not the original sender. Without Enhanced Filtering, Exchange Online's anti-spam and anti-phishing filters (EOP) would evaluate the reputation of your gateway rather than the actual sender.

If you enable RejectDirectSend $true but forget to update your SPF record to include your legitimate third-party sending services (e.g., HubSpot, Salesforce, or on-premise scanners), the impact depends on how those services are connected:

  • If these services send "as you" to your own employees and are not routed through an authenticated Partner Connector, those emails will be rejected. They will return a 550 5.7.68 TenantInboundAttribution; Direct Send not allowed error.
  • The RejectDirectSend setting itself primarily impacts inbound traffic to your tenant. However, if your SPF record is missing these services, your outbound mail delivery will suffer significantly. External recipients (like Gmail or Outlook.com) will see an SPF "Hard Fail" or "Soft Fail," leading to your legitimate business emails being marked as spam or rejected entirely.