Skip to content
Info

The following adheres to Send API v3.0

Personalization

Content Formatting

Mailjet system allows to insert data in your text or html parts.

To do so, use [[DATA_TYPE:DATA_NAME]] where:

DATA_TYPE: var for Vars specified in the API call or data for contact data already available on Mailjet system DATA_NAME: name of the data you want to insert

Use vars and custom vars

By using Vars in conjunction with the [[var:VAR_NAME]], you can modify the content of you email.

Example

# This call sends an email to 2 given recipient with global personalization.
curl -s \
	-X POST \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/send \
	-H 'Content-Type: application/json' \
	-d '{
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"Text-part":"Dear passenger, welcome to Mailjet! On this [[var:day]], may the delivery force be with you!",
		"Html-part":"<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this [[var:day]], may the delivery force be with you!",
		"Vars":{"day":"Monday"},
		"Recipients":[{"Email":"passenger1@mailjet.com","Name":"passenger 1"},{"Email":"passenger2@mailjet.com","Name":"passenger 2"}]
	}'

To go further in personalization Vars is also available for each recipient. The main Vars will be overidden by the recipient Vars.

Example

# This call sends an email to 2 recipients with global and contact personalization.
curl -s \
	-X POST \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/send \
	-H 'Content-Type: application/json' \
	-d '{
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"Text-part":"Dear passenger, welcome to Mailjet! On this [[var:day]], may the delivery force be with you! [[var:personalmessage]]",
		"Html-part":"<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this [[var:day]], may the delivery force be with you! [[var:personalmessage]]",
		"Vars":{"day":"Monday"},
		"Recipients":[{"Email":"passenger1@mailjet.com","Name":"passenger 1","Vars":{"day":"Tuesday","personalmessage":"Happy birthday!"}},{"Email":"passenger2@mailjet.com","Name":"passenger 2"}]
	}'

Use contact properties

If the contact you are sending an email to is already in Mailjet system with some contact datas, you can leverage this information to personalize your email.

Use [[data:METADATA_NAME]] or [[data:METADATA_NAME:DEFAULT_VALUE]] to insert data in your content.

DEFAULT_VALUE is the default value that will be used if no data is found.

Refer to the Personalization section for more information on how to add contact properties.

Example

# This call sends an email to the given recipient.
curl -s \
	-X POST \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/send \
	-H 'Content-Type: application/json' \
	-d '{
		"FromEmail":"pilot@mailjet.com",
		"FromName":"Mailjet Pilot",
		"Subject":"Your email flight plan!",
		"Text-part":"Dear [[data:firstname:\"passenger\"]], welcome to Mailjet! May the delivery force be with you!",
		"Html-part":"<h3>Dear [[data:firstname:\"passenger\"]], welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!",
		"Recipients":[{"Email":"passenger1@mailjet.com","Name":"passenger 1"},{"Email":"passenger2@mailjet.com","Name":"passenger 2"}]
	}'

Go further with personalization

Mailjet offers a Templating language that can extend the personalization of your transactional messages. Visit our Transactional templating guide to learn about additional substitutions, modification functions and conditional statements you can use to personalize your messages.