Using mocks to test response logic is certainly the way to go. Testing separately can only bring you to the end - in the end you will need to write some form of integration test that communicates with the network on the mail server to check the assumptions you made for unit tests.
I used to have a virtual machine with an internal development-only mail server. This mail server does not connect directly to the Internet, but if necessary routes through the company's mail server.
Having your own domain controller / mail server gives the developer more control over functions that are usually not allowed through the corporate network.
As for handling various types of responses, I had a project in which we needed to test different types of responses for meeting invitations. We have configured server rules for different email addresses so that a certain processed object or body will automatically respond with acceptance, rejection, etc. The server-side rule is easy to configure - just log in as this user (here a fake domain controller is useful) to open the look and configure the rule. More complex rules can be configured as part of the Exchange "Event Sink" .
However, as suggested earlier, you should strive to separate the processing of the response from the sending action. This way you can test the processing without the overhead of the environment.
source share