Skip to content

Latest commit

 

History

History
134 lines (81 loc) · 5.86 KB

_SMTP_relay.md

File metadata and controls

134 lines (81 loc) · 5.86 KB

SMTP Relay

Postfix Installation

You can configure your Postfix to send via in.mailjet.com relay, depending on the sender, by following these steps:

In this example, all outgoing emails are sent directly to Mail eXchangers (MX), except when From is *@example.com or example@example.net, which are going through Mailjet.

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).

In /etc/postfix/main.cf (remove relayhost).
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
In /etc/postfix/sender_relay, list addresses that must go through a relay.
@example.com in.mailjet.com
example@example.net in.mailjet.com
In /etc/postfix/sasl_passwd, provide credentials for each address listed in /etc/postfix/sender_relay.
@example.com apikey:secretkey
example@example.net apikey2:secretkey2
Don't forget the following commands.
cd /etc/postfix
chmod 600 sasl_passwd
chown root:root sasl_passwd
postmap sasl_passwd sender_relay
postfix reload

Other configurations

Custom Headers

When using SMTP relay, you can use the following custom headers to specify how Mailjet will handle your message

X-Mailjet-Campaign

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 alphanumeric value of your choice (space, dash and underscore are also accepted), up to 255 characters long on one line.

X-Mailjet-DeduplicateCampaign

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 recipient email address, it will not block a message sent to the same person on two different email addresses.

X-MJ-CustomID

This custom value will help you track your message more easily.

X-MJ-EventPayload

If you need more than an ID, no problem: insert a payload to your messages, using any format (XML, JSON, CSV…)

X-Mailjet-TrackOpen

This header indicates whether or not you want to activate the open tracking on the concerned message. This option will override your tracking options set on your user account.

  • 0: disable the tracking
  • 1: enable the tracking

X-Mailjet-TrackClick

This header indicates whether or not you want to activate or not the click tracking on the concerned message. This option will override your tracking options set on your user account.

  • 0: disable the tracking
  • 1: enable the tracking

X-Mailjet-Prio

The header manages the different types of email by defining up to four priority levels. More information

X-MJ-TemplateLanguage

This header is related to the processing of the template language. It activates the template language processing. By default the template language processing is deactivated. Use 1 to activate.

More information on transactional templating

X-MJ-TemplateID

This header allows you to pass the ID of the template stored on the Mailjet system.

More information on transactional templating

X-MJ-Vars

This header allows you to pass a JSON encoded array of variables that can be used with the templating language.

Example: {"varname1": "value1","varname2": "value2", "varname3": "value3"}

X-MJ-TemplateErrorReporting

This header is related to the processing of the template language. It defines the email address, to which a carbon copy with the error message is sent.

More information on transactional templating

X-MJ-TemplateErrorDeliver

This header is related to the processing of the template language. It defines if the message is delivered when an error is discovered in the templating language. By default the delivery is deactivated. Use deliver to let the message be delivered to the recipient, 0 to stop it.

More information on transactional templating

X-MJ-MonitoringCategory

This header is related to the real-time monitoring. It defines the name of the monitoring category the message will be attached to.

More information on real-time monitoring