{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/template_language/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Using SMTP with Template Language","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Enable Mailjet template language over SMTP using X-MJ-TemplateID, X-MJ-TemplateLanguage, X-MJ-Vars, and X-MJ-TemplateErrorReporting SMTP headers.","image":"https://dev.mailjet.com/og-image.png","lang":"en-US","keywords":["Mailjet API","Email API","Content API","SMTP Relay","transactional email","email delivery","Send API","email templates","developer documentation"],"meta":[{"name":"og:type","content":"website"},{"name":"og:site_name","content":"Mailjet Developer Documentation"},{"name":"twitter:card","content":"summary_large_image"},{"name":"robots","content":"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"},{"name":"googlebot","content":"index, follow, max-snippet:-1, max-image-preview:large"}],"jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://dev.mailjet.com/#organization","name":"Mailjet","alternateName":"Sinch Mailjet","url":"https://www.mailjet.com","logo":"https://assets.mailjet.com/lib/images/mailjetLogo/mj_logo_with_text_color.png","parentOrganization":{"@type":"Organization","name":"Sinch","url":"https://www.sinch.com"}},{"@type":"WebSite","@id":"https://dev.mailjet.com/#website","name":"Mailjet Developer Documentation","description":"Official developer documentation for the Mailjet Email API, Content API and SMTP Relay.","url":"https://dev.mailjet.com/","inLanguage":"en-US","publisher":{"@id":"https://dev.mailjet.com/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://dev.mailjet.com/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]},"llmstxt":{"hide":false,"title":"Mailjet Developer Documentation","description":"Developer documentation for the Mailjet Email API, Content API and SMTP Relay - guides, API references and code samples for sending, templating and tracking email at scale.","details":{"content":"Mailjet (part of Sinch) provides APIs for sending and managing email.\n\nThis documentation covers four main areas:\n\n- **Email API** - the Send API (v3 and v3.1) for transactional and marketing email,\n  plus contact management, segmentation, campaigns, statistics, webhooks, the Parse API\n  and the Mailjet Templating Language.\n- **Content API** - programmatic management of email templates, template contents,\n  images, labels and authentication tokens (v1).\n- **SMTP Relay** - sending through Mailjet's SMTP servers, including custom headers.\n- **API Reference** - the complete, generated reference for every endpoint, built directly\n  from the OpenAPI specifications.\n\nBase URL for all REST APIs: `https://api.mailjet.com`.\nAuthentication uses HTTP Basic auth with an API key and secret key.\n\n## Machine-readable entry points\n\nPrefer these when you need the API surface in as few requests as possible:\n\n- `/openapi/openapi-mailjet.md` - the **complete** Email API reference (every endpoint,\n  grouped by resource) as a single Markdown document.\n- `/openapi/openapi-passport.md` - the **complete** Content API reference as a single\n  Markdown document.\n- `/_bundle/openapi/openapi-mailjet.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Email API.\n- `/_bundle/openapi/openapi-passport.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Content API.\n- `/sitemap.xml` - every indexable URL on this site.\n\nEvery page on this site is also available as clean Markdown by appending `.md` to its URL."},"sections":[{"title":"Email API","description":"Sending, contacts, campaigns, statistics, webhooks and templating.","includeFiles":["docs/email-api/**/*.md"],"excludeFiles":[]},{"title":"Content API","description":"Manage templates, template contents, images, labels and tokens.","includeFiles":["docs/content-api/**/*.md","docs/content-api.md"],"excludeFiles":[]},{"title":"SMTP Relay","description":"Send email through Mailjet's SMTP servers.","includeFiles":["docs/smtp-relay/**/*.md"],"excludeFiles":[]},{"title":"API Reference","description":"Complete generated reference for every Mailjet API endpoint.","includeFiles":["openapi/openapi-mailjet.yaml","openapi/openapi-passport.yaml","docs/api-reference/**/*.md"],"excludeFiles":[]},{"title":"Migrating from Mandrill","description":"Guides for switching from Mandrill to Mailjet.","includeFiles":["docs/mandrill/**/*.md"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"using-smtp-with-template-language","__idx":0},"children":["Using SMTP with Template Language"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mailjet also allows you to take full advantage of the template language when using Mailjet's ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/smtp-relay/smtp-overview"},"children":["SMTP Relay"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To methods are available to provide the message content:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["using the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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 :"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-MJ-TemplateID"]}," : id or name of the template"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-MJ-TemplateLanguage"]}," : set to true to have the templating language interpreted"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-MJ-TemplateErrorReporting"]}," : Email Address where a carbon copy with error message is sent to"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["deliver"]}," to force the message be delivered to the recipient and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}," to stop it."," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Mj-TemplateLanguage"]}," header and set it to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},"."]}]},"headings":[{"value":"Using SMTP with Template Language","id":"using-smtp-with-template-language","depth":1}],"frontmatter":{"title":"Templating Language SMTP","seo":{"description":"Enable Mailjet template language over SMTP using X-MJ-TemplateID, X-MJ-TemplateLanguage, X-MJ-Vars, and X-MJ-TemplateErrorReporting SMTP headers.","title":"Using SMTP with Template Language"}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/template_language/template_smtp","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}