The Test-Mailflow PowerShell cmdlet allows you to test the delivery of email between two mailboxes. The test will be performed using system mailboxes or you can optionally specify other mailboxes to test.

Running the cmdlet on a Mailbox server will test the local server.

[PS] C:\>Test-Mailflow

RunspaceId         : aecc19a4-5571-43cf-affd-b893db3cfab9
TestMailflowResult : Success
MessageLatencyTime : 00:00:45.1720635
IsRemoteTest       : False
Identity           :
IsValid            : True
ObjectState        : New

Notice that the output includes the result (eg, “Success”) as well as the message latency. So not only can are you able to test that mail flow is working, but you can also see whether email delivery is slow, possibly indicating a server or network issue somewhere.

The Test-MailFlow cmdlet can be used to test mail flow between two Mailbox servers, as long as each server has at least one active mailbox database at the time (so that there is a system mailbox available on each server).

[PS] C:\>Test-Mailflow E15MB1 -TargetMailboxServer E15MB2

RunspaceId         : aecc19a4-5571-43cf-affd-b893db3cfab9
TestMailflowResult : Success
MessageLatencyTime : 00:00:05.4297550
IsRemoteTest       : True
Identity           :
IsValid            : True
ObjectState        : New

Note, the above example works if the server E15MB1 is the local server that you’re running the cmdlet on. You may receive an error if you try to specify a remote server there.

In addition to specifying a server to test, you can also specify a database.

[PS] C:\>Test-Mailflow E15MB1 -TargetDatabase "Mailbox Database 2"

RunspaceId         : aecc19a4-5571-43cf-affd-b893db3cfab9
TestMailflowResult : Success
MessageLatencyTime : 00:00:55.9304181
IsRemoteTest       : True
Identity           :
IsValid            : True
ObjectState        : New

Or you can be even more specific by testing mail flow to an email address.

[PS] C:\>Test-Mailflow E15MB1 -TargetEmailAddress paul.cunningham@exchange2013demo.com

RunspaceId         : aecc19a4-5571-43cf-affd-b893db3cfab9
TestMailflowResult : Success
MessageLatencyTime : 00:00:38.2712800
IsRemoteTest       : True
Identity           :
IsValid            : True
ObjectState        : New

Test-MailFlow is the cmdlet that I used to create this mail flow heat map script.

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. J. D. Smith

    IS there a way to diagnose a failure to a valid external email address with this cmdlets? we are having a issues with one particular domain that is hosted on google mail.

  2. Ted Uyesaka

    Is there a baseline for the message latency/time to deliver?

    Thanks

  3. Deb

    Hi Paul,
    Thanks for the article.

    We run a script to check health of exchange 2013 servers. Suddenly we observed a test-mailflow error on a single server under DAG. For all the other servers it is ok.

    While executing the command test-mailflow on ps we have seen the following error.

    PS] C:\Windows\system32>Test-Mailflow
    Microsoft.Mapi.MapiExceptionADPropertyError]: MapiExceptionADPropertyError: Unable to submit message. (hr=0x80004005, ec=2418)
    iagnostic context:
    Lid: 40487 EMSMDBMT.EcDoRpcExt2 called [length=46]
    Lid: 56871 EMSMDBMT.EcDoRpcExt2 returned [ec=0x0][length=248][latency=15]
    Lid: 52176 ClientVersion: 15.0.1130.7
    Lid: 50032 ServerVersion: 15.0.1130.7
    Lid: 23226 — ROP Parse Start —
    Lid: 27962 ROP: ropSubmitMessage [50]
    Lid: 17082 ROP Error: 0x972
    Lid: 27745
    Lid: 21921 StoreEc: 0x972
    Lid: 27962 ROP: ropExtendedError [250]
    Lid: 1494 —- Remote Context Beg —-
    Lid: 41788
    Lid: 44092
    Lid: 61736 StoreEc: 0x972
    Lid: 63016 dwParam: 0x32
    Lid: 39640 StoreEc: 0x972
    Lid: 10786 dwParam: 0x0 Msg: 15.00.1130.005:
    Lid: 1750 —- Remote Context End —-
    Lid: 26849
    Lid: 21817 ROP Failure: 0x972
    Lid: 60547 StoreEc: 0x972
    Lid: 21966
    Lid: 30158 StoreEc: 0x972
    + CategoryInfo : InvalidData: (:) [Test-Mailflow], RecipientTaskException
    + FullyQualifiedErrorId : [Server=,RequestId=91d9812e-8e65-4080-9413-c86dba4bc50e,TimeStamp=05/04/2017 10:38:06] [FailureCategory=Cmdlet-RecipientTaskException] 5AF9971A,Microsoft.Ex
    change.Monitoring.TestMailFlow

    1)If we run Test-mailflow -targetserverFQDN from the problematic server where source server is the problematic server the above error comes.

    2)If we run Test-mailflow -targetserverFQDN where destination server is the problematic one

    RunspaceId : 0797a835-fc16-4f55-9a97-414d8a8ca3f5
    TestMailflowResult : *FAILURE*
    MessageLatencyTime : 00:00:00
    IsRemoteTest : True
    Identity :
    IsValid : True
    ObjectState : New

    3)If we run Test-mailflow -target email address from the problematic server the above error is coming.

    For other server we are getting a mail from system mailbox.

    There are databases on the problematic server and mail flow is working fine. Can you please help to find out the cause.

    1. Avatar photo

      The Test-* cmdlets have all kinds of issues these days with the latest versions of Exchange. Some of them still work okay but some of them, like Test-MailFlow, throw errors when there’s no actual problems.

      1. Debmallya

        Hi Paul ,
        Thanks for your reply.This is interesting as there were no changes on the server (Like CU or anything) and the thing is happening on a single server only.

  4. Remon

    Hello Paul,

    Thank you for your fast response

    I got the below NDR

    Remote Server at cloud4rain.com (213.199.154.106) returned ‘400 4.4.7 Message delayed’
    12/20/2016 1:00:38 AM – Remote Server at cloud4rain.com (213.199.154.106) returned ‘441 4.4.1 Error encountered while communicating with primary target IP address: “Failed to connect. Winsock error code: 10060, Win32 error code: 10060.” Attempted failover to alternate host, but that did not succeed. Either there are no alternate hosts, or delivery failed to all alternate hosts. The last endpoint attempted was 213.199.154.106:25’

  5. Remon

    Hello Paul,

    I have new environment contains one DC, CAS and Mailbox 2013 all of them installed on OS windows 2012 , each role installed on separated Server , i can receive external and internal mails , but my issue is that i can send external mails , all outbound mail stuck in queue , I did a a lot of troubleshooting with no progress , so I need your help

    1. Avatar photo

      There’s a lot of information around for search terms like “Exchange 2013 mail stuck in queue”, which should lead you to the root cause of your problem (there’s a few common issues). Often it’s DNS related, a problem with the DNS config on the Exchange servers themselves.

  6. kofi

    RunspaceId : a8a0adbf-59e9-49b7-baa1-b220885cfbe9
    TestMailflowResult : *FAILURE*
    MessageLatencyTime : 00:00:00
    IsRemoteTest : False
    Identity :
    IsValid : True
    ObjectState : New

    I am getting these results what should i check

  7. Mukhan

    Hi Paul,

    I am getting below error while sending it to specific users and want to track what is blocking these messages;
    ________________________________________________________________________________________________________

    abc@externaldomain.com
    Your message wasn’t delivered due to a permission or security issue. It may have been rejected by a moderator, the address may only accept e-mail from certain senders, or another restriction may be preventing delivery.
    The following organization rejected your message: ISPserver.com

    Diagnostic information for administrators:
    Generating server: mail.mydomain.com
    abc@externaldomain.com
    ISPserver.com. #550 5.7.1 Recipient domain check. ##
    Original message headers:

    ________________________________________________________________________________________________________

  8. Ranjeeva Wijayaratne

    Hi Paul

    I work for an MSP and one of the biggest issues we have is making sure we know when email has stopped working for our customers. One of our developers created an app which sent an email from our servers to the clients server and checked for a reply. the app would alert us if there was a delay in receiving the email after a specific time. The only issue with this was that about 6 weeks later we got Black listed for Spam.

    My question is can this command be used to test out going and incoming mail, and if it can be from your knowledge is there away to generate an alert that can be monitored?

    1. Ken Widmaier

      Ranjeeva,

      I was thinking exactly the same thing with regards to backpressure alerting. Have you come up with a way to properly alert?

      Thanks.

  9. ravi

    what is the default email flow latency on exchange 2013? This is what i have got on my exchange server.

    RunspaceId : e6eb99d6-87a6-4358-8ff1-77faf20b244b
    TestMailflowResult : Success
    MessageLatencyTime : 00:00:02.2233530
    IsRemoteTest : False
    Identity :
    IsValid : True
    ObjectState : New

  10. Terrence Baptiste

    Great article but i have a question. Is there a way to exclude servers that don’t hold an active DB copy from the list to test against?

  11. Casey Jones

    Hello Paul,

    I was wondering if there is anyway to dictate which system mailbox the test-mailflow commandlet uses by default?

    For example, I have an Exchange 2007 mailbox server with multiple Storage Groups and one database per SG. However, the test-mailflow commandlet always uses the same system mailbox from my third Storage Group even though all databases have their own system mailbox.

    Command syntax: Test-MailFlow -Identity MBXServer01 -Verbose

    Thanks,

Leave a Reply