programming code abstract screen of software developer
Photo by Markus Spiske temporausch.com on Pexels.com

Introduction

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 learntechfuture.com into Office 365.
  • MX Record of the domain isn’t pointing to learntechfuture-com.mail.protection.outlook.com
  • Tenant Default Domain is LABTestSJ.onmicrosoft.com
  • Accidenetly forgot to allow distribution group EOPTestingGroup@cvent.com  to receive email from internet.

Where to look for delivery failures ?

  • Message Tracking

Get-MessageTrace -SenderAddress postmaster@LabTestSJ.onmicrosoft.com

Get-MessageTrace -SenderAddress postmaster@<tenantname>.onmicrosoft.com

  • Quarantine Page under Compliance Center.

https://protection.office.com/mailflow/dashboard

  • Have a script to look for email from last one hour from postmaster@LabTestSJ.onmicrosoft.com 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 postmaster@LABTestSJ.onmicrosoft.com -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.

Advertisement