{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/mandrill/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"SMTP Relay - Migrating from Mandrill","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Configure Postfix for Mailjet SMTP relay with sender-dependent auth, plus custom headers X-Mailjet-Campaign, X-MJ-CustomID, and X-Mailjet-TrackOpen.","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":[]},"priority":0.3},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"smtp-relay","__idx":0},"children":["SMTP Relay"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["##Postfix Installation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can configure your Postfix to send via in.mailjet.com relay, depending on the sender, by following these steps:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this example, all outgoing emails are sent directly to Mail eXchangers (MX), except for when from is *@example.com or example@example.net which are going through Mailjet."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Caution, for Postfix, a sender is not the From: but the sender envelope passed to sendmail (in the 5th mail() argument: -fexample@example.com or in PHP config php.ini : sendmail_path = /path/to/sendmail -t -i -fexample@example.com)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In /etc/postfix/main.cf (remove relayhost)."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"smtp_sender_dependent_authentication = yes\nsender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay\nsmtp_sasl_auth_enable = yes\nsmtp_sasl_security_options = noanonymous\nsmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In /etc/postfix/sender_relay, list addresses that must go through a relay."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"@example.com in.mailjet.com\nexample@example.net in.mailjet.com\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In /etc/postfix/sasl_passwd, provide credentials for each address listed in /etc/postfix/sender_relay."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"@example.com apikey:secretkey\nexample@example.net apikey2:secretkey2\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Don't forget the following commands."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"cd /etc/postfix\nchmod 600 sasl_passwd\nchown root:root sasl_passwd\npostmap sasl_passwd sender_relay\npostfix reload\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["##Other configurations"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Desktop email clients (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/support/how-do-i-change-my-smtp-settings-in-outlook,98.htm"},"children":["Outlook"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/apple-mail-smtp-setup"},"children":["Apple Mail"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/thunderbird-smtp-setup"},"children":["Thunderbird"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["MTA & MDA (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/code/exim"},"children":["exim"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Frameworks and Languages (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/code/php"},"children":["Php"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/code/java"},"children":["Java"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/code/asp"},"children":["Asp.net"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/code/php/zend"},"children":["Zend"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/docs/code/php/codeigniter"},"children":["CodeIgniter"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Webmail (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://uk.mailjet.com/support/how-to-set-up-mailjet-s-smtp-with-gmail,110.htm"},"children":["Gmail and Google Apps"]},")"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["##Custom Headers"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When using SMTP relay, you can use the following custom headers to specify how Mailjet will handle your message"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["###X-Mailjet-Campaign"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This header value must be unique for all emails belonging to a specific campaign. This will regroup emails into only one line in your dashboard, and provide cool reports !"," ","It can be an alpha-numeric value of your choice (space, dash and underscore are also accepted), of up to 255 characters in only one line."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["###X-Mailjet-DeduplicateCampaign"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In combination with X-Mailjet-Campaign, this boolean (true, yes, y, 1) indicates that you do not wish to send a message inside the campaign twice to the same recipient. In this case, we check that the recipient hasn’t been sent the message, or otherwise block any duplicate (only the first message goes through)."," ","Please note that this is based on the recipient's email address, it will not block a message sent to the same person on two different email addresses."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["###X-MJ-CustomID"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This custom value will help you track your message more easily."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["###X-MJ-EventPayload"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you need more than an ID, no problem: insert a payload to your messages, using any format (XML, JSON, CSV…)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["###X-Mailjet-TrackOpen"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This boolean (0 or 1) indicates whether you want to activate or not the open tracking on the concerned message. This option overrides your tracking options set on your user account."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["###X-Mailjet-TrackClick"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This boolean (0 or 1) indicates whether you want to activate or not the click tracking on the concerned message. This option overrides your tracking options set on your user account."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["###X-Mailjet-Prio"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This header manages the different types of email by defining up to four priority levels."," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://app.mailjet.com/docs/email-priority-management"},"children":["More information"]}]}]},"headings":[{"value":"SMTP Relay","id":"smtp-relay","depth":1}],"frontmatter":{"title":"Smtp Relay","seo":{"title":"SMTP Relay - Migrating from Mandrill","description":"Configure Postfix for Mailjet SMTP relay with sender-dependent auth, plus custom headers X-Mailjet-Campaign, X-MJ-CustomID, and X-Mailjet-TrackOpen.","priority":0.3}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/mandrill/smtp-relay","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}