The following adheres to Send API v3.0
To send an email, you need the following mandatory properties:
FromEmail: a verified Sender addressRecipients: list with at least one Email addressText-part and/or Html-part: content of the message sent in text or HTML format. At least one of these content type needs to be specified. When Html-part is the only content provided, Mailjet will not generate a Text-part from the HTML version.
Optionally, in place of Recipients, you can use To, Cc and Bcc properties. To, Cc and Bcc can't be used in conjunction with Recipients. The properties can contain several recipients separated by comma using the following format john@example.com, <john@example.com> or "John Doe" <john@example.com>`.
Important: Recipients and To have a different behaviors. The recipients listed in To will receive a common message showing every other recipients and carbon copies recipients. The recipients listed in Recipients will each receive an separate message without showing all the other recipients.
# This call sends an email to one 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 passenger, welcome to Mailjet! May the delivery force be with you!",
"Html-part":"<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
"Recipients":[{"Email":"passenger@mailjet.com"}]
}'{
"Sent": [
{
"Email": "passenger@mailjet.com",
"MessageID": 111111111111111
}
]
}When using To, Cc and Bcc instead of Recipients, the email addresses need to be presented as SMTP headers in a string and not as an array.
MessageUUID is the internal Mailjet ID of your message.
MessageID is the unique ID of the message (legacy format). You will be able to use this id to get more information about your message.
Note: If a recipient does not exist in any of your contact list it will be created from scratch, keep that in mind if you are planning on sending a welcome email and then you're trying to add the email to a list as the contact effectively exists already.
# This call sends an email to two recipients in To and one recipient in CC.
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! May the delivery force be with you!",
"Html-part":"<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
"To":"Name <passenger@mailjet.com>, Name2 <passenger2@mailjet.com>",
"CC":"Name3 <passenger@mailjet.com>"
}'