Inspect the queue

Shows waiting messages with count, destination and last error: the first look when mail is not arriving.

Warteschlange

PowerShell (Windows)

Get-Queue (Exchange) Built-in

Get-Queue | Sort-Object MessageCount -Descending |
  Format-Table Identity, Status, MessageCount, NextHopDomain, LastError -AutoSize

IIS SMTP Pickup Built-in

Get-ChildItem "$env:SystemRoot\System32\inetsrv\mailroot\Queue" | Measure-Object

Unix shell (bash)

mailq Built-in

mailq | tail -1
mailq | head -30

postqueue / exim Add-on tool

postqueue -p | tail -1
exim -bpc

Exchange cmdlets need the Exchange Management Shell. On Linux the command depends on the MTA: mailq works for Postfix and Exim, the detail commands differ.

Examine a message

Shows a single waiting message with sender, recipients, headers and the reason it failed.

PowerShell (Windows)

Get-Message (Exchange) Built-in

Get-Message -Identity "3F2A81C0B45" | Format-List Identity, Subject, FromAddress, Recipients, Status, LastError, Queue

Get-MessageTrackingLog Add-on tool

Get-MessageTrackingLog -MessageId "3F2A81C0B45" -Start (Get-Date).AddDays(-1) | Format-Table Timestamp, EventId, Source, Recipients

Unix shell (bash)

postcat Built-in

postcat -qv 3F2A81C0B45

exim Add-on tool

exim -Mvh 3F2A81C0B45
exim -Mvb 3F2A81C0B45

Force delivery

Triggers delivery of all waiting messages right away instead of waiting for the next retry run.

PowerShell (Windows)

Retry-Queue (Exchange) Built-in

Get-Queue | Where-Object { $_.Status -eq "Retry" } | Retry-Queue -Resubmit $true

Force-Resubmit Add-on tool

Get-Queue | Where-Object { $_.MessageCount -gt 0 } | ForEach-Object { Retry-Queue -Identity $_.Identity }

Unix shell (bash)

postqueue Built-in

postqueue -f

exim Add-on tool

exim -qff

Useful right after fixing an outage. With a very large queue this creates a load spike at the destination.

Delete a message

Removes a message from the queue, optionally without a non-delivery report.

PowerShell (Windows)

Remove-Message (Exchange) Built-in

Remove-Message -Identity "3F2A81C0B45" -WithNDR $false -Confirm:$false

Remove-Queue Add-on tool

Get-Queue | Where-Object { $_.Status -eq "Suspended" } | Get-Message | Remove-Message -WithNDR $false -Confirm:$false

Unix shell (bash)

postsuper Built-in

postsuper -d 3F2A81C0B45
# ALLE zurueckgestellten loeschen: postsuper -d ALL deferred

exim Add-on tool

exim -Mrm 3F2A81C0B45

Not reversible. Inspect the message first and save it if needed (postcat, Get-Message).

Find deferred messages

Filters the queue by an error text or response code to find the pattern behind an outage.

PowerShell (Windows)

Get-Queue (Exchange) Built-in

Get-Queue | Where-Object { $_.LastError -like "*550*" } |
  Format-Table Identity, MessageCount, NextHopDomain, LastError -AutoSize

Get-MessageTrackingLog Add-on tool

Get-MessageTrackingLog -EventId FAIL -Start (Get-Date).AddHours(-24) | Format-Table Timestamp, RecipientStatus

Unix shell (bash)

mailq / grep Built-in

mailq | grep -B1 "550" | head -40

postqueue Add-on tool

postqueue -j | grep -o '"recipients".*' | head -20

Other areas