One of the most challenging aspects of implementing a real system which connects to the email system is being able to test sufficiently. There is a simple trick which can be immensely helpful: email testing mode.
Email testing mode is nothing more than a single global setting that reroutes all email to a single fixed address, and it only change the to address in the message … all other aspects of the message remain unchanged. This allows you to
- create any number of users, with any number of email addresses. Each user can have their own email address, and you can if you wish use the real email address of real people. Encryption and settings that are user specific can be tested. Email will never actually be set to those people from this server.
- use realistic email addresses instead of being stuck with “example.com” or other addresses that you know do not cause problems.
- realistic roles and relationships, you can test large groups, small groups. You can set up social network relationships without limitation. All of the mail will be delivered to one actual email inbox, instead of the email address for the user, so there is no limitation.
- access control, different users will have different levels of access, and may view the system differently, and receive differing amounts of information in the email messages. By actually setting up different user accounts with differing levels of access, you can actually test these capabilities, but still receive the email to a single place to review it.
- non distorted, the system does not need to be set up in a distorted manner around a single user
- turn on and off, you can do some testing in place even on a production machine. Turn on email testing mode, and do some operations, and none of the real users will see those email messages. Then turn off later to return the server to regular functioning.
That is it, simply a global email address that overrides the to (and cc) addresses just at the point of sending the email. All the rest of the processing around formation of the message, and tracking of the message, is the same. Just the mailbox that the message is delivered to is affected, allowing the developer to capture and see all email generated by the system.