Using template with SMTP

Mailjet also allows you to take full advantage of the template language when using Mailjet's SMTP relay.

To methods are available to provide the message content:

  • using the X-MJ-TemplateID SMTP header : pass the ID or the name of the template stored on Mailjet
  • sending a message containing some template language.

You can use the following SMTP headers to leverage the template language :

  • X-MJ-TemplateID - id or name of the template

  • X-MJ-TemplateLanguage - set to true to have the templating language interpreted

  • X-MJ-TemplateErrorReporting - Email Address where a carbon copy with error message is sent to

  • X-MJ-TemplateErrorDeliver - Define whether the message should be delivered when an error is discovered in the templating language. By default the delivery is deactivated and the message will be blocked. Set the property to deliver to force the message be delivered to the recipient and 0 to stop it.

  • X-MJ-Vars - Global variables used for personalisation in a JSON format


In order to have the template language interpreted through the SMTP relay, you must provide X-Mj-TemplateLanguage header and set it to true.