programming code abstract screen of software developer
Photo by Markus Spiske on


It is crucial to look for bounce messages originating from office 365. Specially when you are adding a domain to Office 365, which was in G-Suite or any other system.

There are high chances that some errors will occur and bounces would be generated.

Scenario :

  • Added domain into Office 365.
  • MX Record of the domain isn’t pointing to
  • Tenant Default Domain is
  • Accidenetly forgot to allow distribution group  to receive email from internet.

Where to look for delivery failures ?

  • Message Tracking

Get-MessageTrace -SenderAddress

Get-MessageTrace -SenderAddress postmaster@<tenantname>

  • Quarantine Page under Compliance Center.

  • Have a script to look for email from last one hour from and then perform a reverse query and perform quick search in the same time frame.
  • I wrote below script quickly, I will improvise this and post this again but for now, it should do your job.
# First connect to Exchange Online and then run this script
$StartDDBounce = (get-date).addhours(-6)
$EndDDBounce = get-date

# Find All messages sent by postmaster in last 6 hours containing Undeliverable in Subject
# FYI Get-MessageTrace can return message data for the last 10 days. Max 1000000 result can be returned

$Bounce = Get-MessageTrace -SenderAddress -StartDate $StartDDBounce -EndDate $EndDDBounce |
where {$_.Subject -like "Undeliverable*"}| 
select Received, Subject

$result = @()
foreach ($EachBounce in $Bounce)
[datetime]$EndDT = $EachBounce.Received
[datetime]$StartDT = ($EachBounce.Received).addminutes(-10)
$OriginalMsg = $EachBounce.subject -replace "Undeliverable: "
# Look for Failed Message Only
$result += Get-MessageTrace -StartDate $StartDT -EndDate $EndDT -Status Failed | where {$_.Subject -like $OriginalMsg} | select Received, SenderAddress, RecipientAddress, Subject, MessageId, Status, MessageTraceId
$result | Export-Csv $Home\Desktop\Bounces.csv -NoTypeInformation

Thank you for reading and Please suggest improvement.