Email Templates

Overview 

Email templates allow you to design, edit, and host HTML email templates on Mailtrap Email Delivery Platform and reference them via API.

You don’t need to save the template in your code, you can upload HTML or use one of the ready-made templates, then call the template via API and send it to your recipients.

Doing that gives you the flexibility to easily change the template code without committing to your codebase.

Additionally, email templates support Variables and Mailtrap uses Handlebars as a template engine. 

You can put {{user_name}} into your template and pass “John” as the “user_name” value via API. Afterward, Mailtrap renders the rest of the HTML and replaces the variable with the value. Handlebars also support more logic operators. 

Email Templates are available for all Email Sending users. And each email sent via templates is counted towards your quota.

How to create a template

To create a template you need to add, set up, and verify a sending domain in advance. Check our Getting Started Guide if you need any help with that.  

Important Note: To be able to send emails using email templates, your domain needs to be verified.

Template creation - a quick step-by-step guide

1. Navigate to the Email Templates menu and click the Create New Template button 

2. Click the drop-down menu to select one of your domains, then click the Select button to choose a template and confirm with the Create Template button. 

3. Proceed to review and edit the template, then click Save to complete the action. (Read more about editing options in the following sections.) 

Things to remember 

Each account can have up to 100 email templates. If you need more - please contact Support.

As mentioned, you can create an email template in HTML or use ready templates from the gallery. Plus, you can customize the ready-made templates to your needs.

The main Email Templates menu features all your saved templates. To quickly access a saved template, just click on it within the main menu.

How to edit and customize your templates

Mailtrap gives you a few options to ensure templates perfectly fit your needs. Here’s what you can do. 

Details tab

Each template is required to have a name, category, and an assigned domain.

Adding an Email category to a template is beneficial because you’ll see the performance stats for each template under Email Categories, where each category equals a template.

For example, you create a template for a welcome email and name it Welcome Email, then use the same naming for the template category.

Reminder: To save changes on your template click the Save Template button. Otherwise, the changes won’t be applied.

Code editing

Each email template needs to have a defined subject, and here you can also use a variable.

As for the content itself, you can edit HTML or Text part, depending on the emails you want to send. 

The editor supports Find and Replace options, and you can use Cmd+F or Win+F as a hotkey to reveal a quick search bar.

If your template has an error, that prevents Handlebars from rendering it. You’ll see an error message in the Preview tab and the RAW code that has an error will be highlighted in the Editor.

Also, you can’t save a template with errors. And note that we don’t validate HTML.

Image upload

Mailtrap Templates allow you to use and host your images within our platform. To make things easier, you can upload images from the Code Editor and get a public URL to reference an image in the template under the <img> tag. Here’s a quick guide.

1. Click Upload image in the upper right corner of the Code Editor. 

2. Hit the Upload New button in the following menu and choose an image from your local drive.

3. Once the image is uploaded, you get a confirmation notification. If the file format is unsupported or the image is too big, you’ll get the corresponding error message. 

4. Click the copy icon to copy the image URL to your clipboard, then click Templates to go back to the editing menu.

5. Proceed to add the image to the template body under the <img> tag. You’ll be able to preview it in the template as soon as the asset is added. 

Supported formats: JPG, PNG, GIF

Max file size: 2 MB.

You can delete image assets by clicking on the trashcan icon at the far right of the image. But please note that it can’t be undone, and the templates featuring the image will no longer display the asset.

You can filter the uploads using search. Also, all assets are available within your account and the templates themselves. 

Tip: Use logical names in image filenames. For example - Logo.png, not 1232.png.

Preview

As mentioned earlier, when you change the code, you see real-time changes in the Preview space.

You can switch between Mobile/Desktop previews, but note that this isn’t an exact rendering of your email, just an emulation to see the visual representation of the code for reference. 

Test Data

Mailtrap automatically parses your template and shows all the variables we found. The Test Data tab helps you to get a preview of the object variables, which you pass via Mailtrap Sending API to send your email on production.

By default, as a value, we put a variable name and add the “Test_” prefix.

You can change the values, and that’s reflected under the email Preview. But these changes are not saved even if you click the Save Template button. And when you leave the page, we prefill values again with “Test_” values.

Send test

Mailtrap Templates allow you to test your template. Hit the Send Test button and the email will be sent to your user email address registered with Mailtrap. 

Important Notes:

To send a successful test, you need to save your template first. This step also assumes that your domain is verified and trusted and that the template itself doesn’t have any Handlebars errors. 

Keep in mind that each test email is billed over your quota.

Integrations and API to send templates

In the integrations tab, you can find ready-made examples of how you can send emails using different languages using Mailtrap API. 

Please note; the main ID of your Template is its UUID, which can be found under the Integrations tab. Use the UUID to reference a template in Mailtrap Sending API.

Click here if you want to access API docs. 

List of Templates and User permissions

Clicking on Email Templates in the side menu lists all the templates you can access.

Access to templates is managed on a domain level. You need to have Admin access to a domain to manipulate the templates. In case you don’t have Edit rights, you can’t change the template.

Reminder: You can delete a template. But remember that the action is irreversible, so be sure to change the sending code after deletion. When the template gets deleted, the UUID gets deleted as well, and Mailtrap won’t be able to render the template.

Still need help? Contact Us Contact Us