Set up DMARC and see who's sending email using your brand's domain.

Handling email in your test environment

We’ve had a few support requests asking if Postmark has a sandbox environment for testing. While we don’t have an actual test environment, we do have some methods and recommendations on how to properly test email in your development environment.

Subscribe to be notified when we share more developer insights.

Why have a test environment? #

Let me explain why a test environment is important. When sending email from a staging or development environment, the first thing you want to avoid is sending email to real users by mistake. Over the years, this bit us a few times when trying to use some “real data” for testing. The other reason is so you can inspect the outbound messages and make sure they both display correctly, but have the proper headers and so on. Waiting until a production launch for this could be a disaster.

The solution #

There are two great solutions to properly test when it comes to outbound email.

Testing with the API

Postmark allows you to pass the API Key “POSTMARK_API_TEST” instead of your real API Key. This way, you can test that the request is valid and test against the various API responses from Postmark. This method will not allow you to inspect the messages, but it helps ensure that your messages will be accepted by the API.

Testing with SMTP

If you use the SMTP option for sending email, there is was an excellent app (Mac OS X only) to handle this for you, called MockSMTP, now available as open source code on GitHub. With MockSMTP, it will create a local SMTP server that you can point to in your local development environment. When emails are sent, you can view the actual display of the content as well as the RAW content of the message. This goes a long way when it comes to inspecting message content and ensuring the proper email events are triggered in your app, all without the risk of sending live emails.

Chris Nagele

Chris Nagele

Love to travel with the wife and kids. Wannabe race car driver. Not so healthy obsession with Building Science.