Previewing and Sending Test Emails

April 28, 2017 Contributors

This article will walk you through the steps of previewing your email and sending test emails in SparkPost.

In the SparkPost UI, you can use the “Preview” mode of the template editor to render your HTML or text templates and send tests of your template.

There are some limitations on test sends; you can only send up to five (5) people at a time. DO NOT USE THIS FOR PRODUCTION TRANSMISSIONS!

The following example code is used to illustrate our preview and test send functionality, but you may use your own content if you wish. To use the preview functionality, login to your SparkPost account and create a new template with the following parameters:

  • Template Name: SparkPost Preview Test Template
  • ID: my-preview-test-template
  • From Name: This is the “human friendly” name that is shown to recipients in their email client
  • From Email (sender): Your user on the valid sending domain
  • From Email (@domain): Must be one of your valid sending domains. Learn how to configure a sending domain in SparkPost
  • Subject: Test Email, Please do not respond
  • Description: This is a simple test template used to test SparkPost’s Preview Functionality
  • Engagement Tracking: Turn on Track Opens and Track Clicks

# The Test HTML Content

# The Test Text Content

# Example Substitution Data

NOTE: You have to have a completed template definition (and any necessary substitution data used in either the TEXT or HTML versions of the template) prior to the “Preview” functionality being enabled.

The last thing we want to do is “Save” our template. The difference between “Save” and “Save & Publish” is:

Usable in Production Requires Override to Use in API Editable State
Save YES YES YES Draft
Save & Publish YES NO NO Published

Click the “Save” button (for this example, so we can easily edit it if something is incorrect).

# To View Your Email in Preview

Once you have your completed template content and have provided the substitution data, you can click the “Preview” button to view your template rendered with your test substitution data. Below is an example of a completed template.

# To Send a Test Email in Preview

Both sparkpost.com and SparkPost Enterprise allow you to set substitution_data, metadata, and options values in the test data screen (accessed by clicking on the “</>TEST DATA” button). For sparkpost.com users, none of these fields are required to send a test message and are optional. For SparkPost Enterprise users, however, you MUST provide a valid binding group name already configured on your system in order for the test message to be sent. Sparkpost.com users have the option of setting an ip_pool to be used by the test message if desired nested in the options object. The screenshot below illustrates both use cases; please note that the capitalized sentences highlight which key value pairs align with the given service.

While you have the Preview window still open (viewing your rendered template with substitution data) you can enter up to five (5) email addresses in the “To” field (it is marked with a message that reads “For testing purposes only”). Then click the “Send Email” button, and your email will be sent to those addresses. You can see an example screenshot below of the preview window (I have added three email addresses to test send with in the example).

BONUS FEATURE: Sending test transmissions also generates REAL webhook events, so you can use it to test those as well.