NAV Navbar
cURL PHP NODE RUBY PYTHON GO JAVA C#
  • Overview
  • Getting Started
  • Verify Your Domain
  • Send transactional email
  • Send API v3.1
  • Send API v3
  • Template API
  • Send marketing campaigns
  • Event API: real-time notifications
  • Statistics
  • Parse API: inbound emails
  • Manage Contacts in bulk
  • GDPR Delete Contacts
  • Domains and DNS
  • Account management
  • SMTP Relay
  • Exclusion List
  • The libraries
  • Google Cloud Platform
  • MJML
  • Need Help?
  • Overview

    About the Mailjet API

    Hello and welcome to the Mailjet Email API!

    The Mailjet API is organized around REST. It has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. All request and response bodies are encoded in JSON, including errors.

    The API is accessed by making HTTPS requests to a specific version endpoint URL. GET, POST, PUT, and DELETE methods dictate how you interact with the available objects.

    Each endpoint has a list of properties and methods you can see in our API Reference.

    Authentication

    All Email API endpoints requests are authenticated using HTTPS Basic Auth. It requires you to provide a username and a password for each API request.

    The username is your API Key and the password is your API Secret Key - you can find them in your API Key Management page. Both keys are generated automatically when your account is created.

    Pagination

    Depending on your request and the endpoint, the results in the response may be paginated. Use the following query parameters to page through the results:

    Name Type Description
    Limit integer The number of results returned per page. The default value is 10, the maximum is 1000.
    Offset integer The index of the first object in the page. For example, if you have set a limit of 100 and want to see objects 101 through 200, then Offset=100
    Sort string Sort the results by a property and select ascending (ASC) or descending (DESC) order. The default order is ascending. Keep in mind that this is not available for all properties. Example: Sort=ArrivedAt+DESC

    Status Codes

    The Mailjet API uses conventional HTTP response codes to indicate the success or failure of an API request. See the full list of status codes for more information.

    Getting Started

    In this section we will guide you through the core features of the Mailjet Email API : sending an email and retrieving information about your sent messages, including engagement statistics (opens, clicks, etc.).

    Let’s start!

    Prerequisites

    To use the Mailjet Email API, you need to:

    1. Create a Mailjet account, then retrieve your API and Secret keys. They will be used for authentication purposes.
    2. Make sure you have cURL installed on your machine, or use one of our official libraries in PHP, Python, Node.js, Java, C#, Go, and Ruby.

      Alternatively, you can use Postman to test the different API endpoints. Click on the button below to import a pre-made collection of examples.

    We also suggest that you create environment variables for your API and Secret keys for easy input.

    export $MJ_APIKEY_PUBLIC='Enter your API Key here'
    export $MJ_APIKEY_PRIVATE='Enter your API Secret here'
    
    setx -m $MJ_APIKEY_PUBLIC "Enter your API Key here"
    setx -m $MJ_APIKEY_PRIVATE "Enter your API Secret here"
    

    Send your first email

    First, define the sender and recipient email as environment variables. Keep in mind that the sender email should be validated in your Mailjet account (your signup email address will be automatically validated).

    export $SENDER_EMAIL='Enter your sender email address here'
    export $RECIPIENT_EMAIL='Enter your recipient email address here'
    

     setx -m $SENDER_EMAIL "Enter your sender email address here"
     setx -m $RECIPIENT_EMAIL "Enter your recipient email address here"
    

    # Run:
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "$SENDER_EMAIL",
                                    "Name": "Me"
                            },
                            "To": [
                                    {
                                            "Email": "$RECIPIENT_EMAIL",
                                            "Name": "You"
                                    }
                            ],
                            "Subject": "My first Mailjet Email!",
                            "TextPart": "Greetings from Mailjet!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
        }'
    
    <?php
    /*
    Run:
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "$SENDER_EMAIL",
                    'Name' => "Me"
                ],
                'To' => [
                    [
                        'Email' => "$RECIPIENT_EMAIL",
                        'Name' => "You"
                    ]
                ],
                'Subject' => "My first Mailjet Email!",
                'TextPart' => "Greetings from Mailjet!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * Run:
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "$SENDER_EMAIL",
                                    "Name": "Me"
                            },
                            "To": [
                                    {
                                            "Email": "$RECIPIENT_EMAIL",
                                            "Name": "You"
                                    }
                            ],
                            "Subject": "My first Mailjet Email!",
                            "TextPart": "Greetings from Mailjet!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # Run:
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> '$SENDER_EMAIL',
            'Name'=> 'Me'
        },
        'To'=> [
            {
                'Email'=> '$RECIPIENT_EMAIL',
                'Name'=> 'You'
            }
        ],
        'Subject'=> 'My first Mailjet Email!',
        'TextPart'=> 'Greetings from Mailjet!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />May the delivery force be with you!'
    }]
    )
    p variable.attributes['Messages']
    
    """
    Run:
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "$SENDER_EMAIL",
                                    "Name": "Me"
                            },
                            "To": [
                                    {
                                            "Email": "$RECIPIENT_EMAIL",
                                            "Name": "You"
                                    }
                            ],
                            "Subject": "My first Mailjet Email!",
                            "TextPart": "Greetings from Mailjet!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    Run:
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "$SENDER_EMAIL",
              Name: "Me",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "$RECIPIENT_EMAIL",
                Name: "You",
              },
            },
            Subject: "My first Mailjet Email!",
            TextPart: "Greetings from Mailjet!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * Run:
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "$SENDER_EMAIL")
                            .put("Name", "Me"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "$RECIPIENT_EMAIL")
                                .put("Name", "You")))
                        .put(Emailv31.Message.SUBJECT, "My first Mailjet Email!")
                        .put(Emailv31.Message.TEXTPART, "Greetings from Mailjet!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// Run:
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "$SENDER_EMAIL"},
                      {"Name", "Me"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "$RECIPIENT_EMAIL"},
                       {"Name", "You"}
                       }
                      }},
                     {"Subject", "My first Mailjet Email!"},
                     {"TextPart", "Greetings from Mailjet!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Then use the code sample to send a message.

    Example API Response:

    {
      "Messages": [
        {
          "Status": "success",
          "To": [
            {
              "Email": "passenger@mailjet.com",
              "MessageUUID": "1ab23cd4-e567-8901-2345-6789f0gh1i2j",
              "MessageID": "1234567890987654321",
              "MessageHref": "https://api.mailjet.com/v3/message/1234567890987654321"
            }
          ],
        }
      ]
    }
    

    Congratulations - you have successfully sent your first email!

    Save the MessageID - we will need it in the next section to access detailed information about the sent email.

    Retrieve sent messages

    # Run :
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/message/$MESSAGE_ID 
    
    <?php
    /*
    Run :
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $response = $mj->get(Resources::$Message, ['id' => $id]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * Run :
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("message")
        .id($MESSAGE_ID)
        .request()
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # Run :
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Message.find($MESSAGE_ID)
    p variable.attributes['Data']
    
    /*
    Run :
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Message
        mr := &Request{
          Resource: "message",
          ID: RESOURCE_ID,
        }
        err := mailjetClient.Get(mr, &data)
        if err != nil {
          fmt.Println(err)
        }
        fmt.Printf("Data array: %+v\n", data)
    }
    
    """
    Run :
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    id = '$MESSAGE_ID'
    result = mailjet.message.get(id=id)
    print result.status_code
    print result.json()
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Message;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * Run :
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Message.resource, ID);
          response = client.get(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// Run :
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Message.Resource,
                ResourceId = ResourceId.Numeric(ID)
             }
             MailjetResponse response = await client.GetAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Now, let’s view the status of the sent message and its configuration specifics.

    Example API response:

    {
      "Count": "1",
      "Data": [
        {
          "ArrivedAt": "2018-01-01T00:00:00",
          "AttachmentCount": "1",
          "AttemptCount": "1",
          "CampaignID": "123456789",
          "ContactAlt": "",
          "ContactID": "987654",
          "FilterTime": "111",
          "ID": "1234567890987654321",
          "Status": "clicked",
          "Subject": "",
          "UUID": "1ab23cd4-e567-8901-2345-6789f0gh1i2j"
          "........................."
        }
      ],
      "Total": "1"
    }
    

    As you can see, the information about the message is quite detailed and includes, among other things:

    In case you want to view the contact email address, or the Subject of the email, add the ShowContactAlt=true and ShowSubject=true as query parameters, respectively.

    # Run :
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/message?ContactAlt=$RECIPIENT_EMAIL 
    
    <?php
    /*
    Run :
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'ContactAlt' => '$RECIPIENT_EMAIL'
    ];
    $response = $mj->get(Resources::$Message, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * Run :
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("message")
        .request({
            "ContactAlt":"$RECIPIENT_EMAIL"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # Run :
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Message.all(contact_alt: "$RECIPIENT_EMAIL"
    )
    p variable.attributes['Data']
    
    """
    Run :
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    filters = {
      'ContactAlt': '$RECIPIENT_EMAIL'
    }
    result = mailjet.message.get(filters=filters)
    print result.status_code
    print result.json()
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Message;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * Run :
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Message.resource)
                      .filter(Message.CONTACTALT, "$RECIPIENT_EMAIL");
          response = client.get(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    /*
    Run :
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Message
        _, _, err := mailjetClient.List("message", &data, Filter("ContactAlt", "$RECIPIENT_EMAIL"))
        if err != nil {
          fmt.Println(err)
        }
        fmt.Printf("Data array: %+v\n", data)
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// Run :
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Message.Resource,
             }
             .Filter(Message.Contactalt, "$RECIPIENT_EMAIL");
             MailjetResponse response = await client.GetAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Alternatively, you can retrieve messages sent to a specific recipient email address, using a query parameter:

    View message history

    # Run :
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/messagehistory/$MESSAGE_ID 
    
    <?php
    /*
    Run :
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $response = $mj->get(Resources::$Messagehistory, ['id' => $id]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * Run :
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("messagehistory")
        .id($MESSAGE_ID)
        .request()
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # Run :
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Messagehistory.find($MESSAGE_ID)
    p variable.attributes['Data']
    
    /*
    Run :
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Messagehistory
        mr := &Request{
          Resource: "messagehistory",
          ID: RESOURCE_ID,
        }
        err := mailjetClient.Get(mr, &data)
        if err != nil {
          fmt.Println(err)
        }
        fmt.Printf("Data array: %+v\n", data)
    }
    
    """
    Run :
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    id = '$MESSAGE_ID'
    result = mailjet.messagehistory.get(id=id)
    print result.status_code
    print result.json()
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Messagehistory;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * Run :
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Messagehistory.resource, ID);
          response = client.get(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// Run :
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Messagehistory.Resource,
                ResourceId = ResourceId.Numeric(ID)
             }
             MailjetResponse response = await client.GetAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    You can track important events linked to the sent emails, for example whether the recipient opened the message, or clicked on a link within.

    Do a GET request on /messagehistory/{message_ID} to retrieve the list of events linked to the email we just sent.

    Example API Response:

    {
        "Count": 4,
        "Data": [
            {
                "EventAt": 1546958313,
                "EventType": "sent",
                ".........................."
            },
            {
                "EventAt": 1546958354,
                "EventType": "opened",
                ".........................."
            },
            {
                "EventAt": 1546958355,
                "EventType": "clicked",
                ".........................."
            }
        ],
        "Total": 4
    }
    

    We can see the event type, as well as a timestamp indicating when it happened. Pretty useful, right?

    Retrieve Statistics

    <?php
    /*
    Run :
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'CounterSource' => 'APIKey',
      'CounterTiming' => 'Message',
      'CounterResolution' => 'Lifetime'
    ];
    $response = $mj->get(Resources::$Statcounters, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * Run :
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("statcounters")
        .request({
            "CounterSource":"APIKey",
            "CounterTiming":"Message",
            "CounterResolution":"Lifetime"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # Run :
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/statcounters?CounterSource=APIKey\&CounterTiming=Message\&CounterResolution=Lifetime 
    
    # Run :
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Statcounters.all(counter_source: "APIKey",
    counter_timing: "Message",
    counter_resolution: "Lifetime"
    )
    p variable.attributes['Data']
    
    """
    Run :
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    filters = {
      'CounterSource': 'APIKey',
      'CounterTiming': 'Message',
      'CounterResolution': 'Lifetime'
    }
    result = mailjet.statcounters.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    Run :
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Statcounters
        _, _, err := mailjetClient.List("statcounters", &data, Filter("CounterSource", "APIKey"), Filter("CounterTiming", "Message"), Filter("CounterResolution", "Lifetime"))
        if err != nil {
          fmt.Println(err)
        }
        fmt.Printf("Data array: %+v\n", data)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Statcounters;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * Run :
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Statcounters.resource)
                      .filter(Statcounters.COUNTERSOURCE, "APIKey")
                      .filter(Statcounters.COUNTERTIMING, "Message")
                      .filter(Statcounters.COUNTERRESOLUTION, "Lifetime");
          response = client.get(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// Run :
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Statcounters.Resource,
             }
             .Filter(Statcounters.Countersource, "APIKey")
             .Filter(Statcounters.Countertiming, "Message")
             .Filter(Statcounters.Counterresolution, "Lifetime");
             MailjetResponse response = await client.GetAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Example API Response

    {
      "Count": "1",
      "Data": [
        {
          "APIKeyID": "123456",
          "MessageClickedCount": "1",
          "MessageDeferredCount": "0",
          "MessageHardBouncedCount": "0",
          "MessageOpenedCount": "1",
          "MessageQueuedCount": "0",
          "MessageSentCount": "1",
          "MessageSoftBouncedCount": "0",
          "MessageSpamCount": "0",
          "MessageUnsubscribedCount": "0",
          "Total": "1"
          "........................."
        }
      ],
      "Total": "1"
    }
    

    The Mailjet API also has a variety of resources that help retrieve aggregated statistics for key performance indicators like opens, clicks, unsubscribes, etc.

    Let's take a look at just one of those resources to give you a sample of the data you can read - we’ll retrieve total aggregated statistics for your API key.

    Next steps

    You have played around with some of the basic functionalities of the Mailjet API, but there is so much more to learn! Continue reading to understand how to make the most out of the available resources.

    Here's a small list of suggestions:

    For full information on all API endpoints, please visit our API Reference.

    Verify Your Domain

    We strongly recommend that you verify the domain or subdomain you will use for sending emails. To do so you have to go to your account settings and add the domain you want to use for sending emails. Once the domain is successfully set up we generate an SPF and a DKIM record for you.

    SPF is a DNS TXT record and acts as a filter. It is used to specify a whitelist of IP addresses. This whitelist can be queried by mail clients to see whether a sender IP is in the list.

    DKIM is another DNS TXT record and contains a public key. We automatically generate a public/private key pair for you after registration. The private key is used to sign every message you send. Email clients can then check your DKIM record and use it to verify the signature. Together, SPF and DKIM form the technical basis of email deliverability.

    Tip: You can find both records together with instructions in your account settings. Go to your account setup page and click on the info button for your domain.

    Once your domain is verified you should add the SPF and DKIM records to your domain using the domain configuration tool of your DNS Provider.

    You can refer to our step-by-step user guides on creating DNS records:

    You can also visit the offical and third-party documentations for DNS providers :

    With some DNS providers the setup can be quite tedious, but we would be happy to help you out. Just contact our support!

    Send transactional email

    Choose sending method

    Mailjet offers two ways to send transactional emails : SMTP Relay or Send API.

    SMTP Relay

    With the Mailjet SMTP Relay you can send emails in an easy way, requiring minimum integration effort on your side.

    The SMTP Relay is useful if you have an existing solution for transactional emailing by SMTP or if you cannot use the Send API. Using the SMTP relay, you have to take care of email headers, MIME type handling and completely format and personalize your message content.

    The best and fastest way to use the SMTP Relay is to have your own local mail server relaying messages to the Mailjet SMTP. Your local mail server will give you reliable management of the messages and connections between our 2 systems. In case of breakage in the connection, your mail server will properly handle the error and retry sending your messages.

    In case you don't have a local mail server, you can still use the SMTP Relay by using one of the many SMTP libraries available or configuring your exiting system (frameworks, CMS, CRM...). However, some of these libraries or systems can lack the advanced error handling necessary to queue and resend the messages in case of an error. The use of Send API can be a better choice as it requires less interactions between our systems and limits the risk of failures. The error handling is also a lot simpler with the API as we are managing the delivery and queuing of your messages for you.

    Using Mailjet's SMTP servers to send your transactional emails is very simple. All you have to do is update your SMTP server settings to use our server as a "relay" or "smarthost" with the credentials provided by Mailjet. The credentials are your $MJ_APIKEY_PUBLIC as a login and $MJ_APIKEY_PRIVATE as a password.

    You can find your SMTP credentials in your Account Setup page

    You can find more information on how to configure the SMTP Relay and custom email headers in our SMTP Relay Guide.

    Send API

    Mailjet's Send API allows you to send transactional emails using our HTTP API, using POST requests. This solution is aimed at users needing a programmatical way to send messages.

    Send API allows to send single messages but also to mutualize the calls by leveraging templating and personalization of the content.

    The API will return a simple response indicating if the message is ready to be processed on the Mailjet system. This makes the error management on your side simple and efficient.

    Choose Send API V3.1

    Send API v3.1 has been designed to be the most intuitive and talkative version of our transactional send APIs. It brings a human-centered payload understanding and improved error reporting.

    Choose Send API V3

    Send API v3 is Mailjet’s traditional transactional Send API. Designed for advanced developers looking for performance and scalability, we mainly advise this version to larger players.

    Requirements

    Verify a Sender

    <?php
    /*
    Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $body = [
        'Email' => "anothersender@example.com"
    ];
    $response = $mj->post(Resources::$Sender, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/sender \
        -H 'Content-Type: application/json' \
        -d '{
            "Email":"anothersender@example.com"
        }'
    
    /**
     *
     * Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("sender")
        .request({
            "Email":"anothersender@example.com"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Sender.create(email: "anothersender@example.com"
    )
    p variable.attributes['Data']
    
    """
    Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    data = {
      'Email': 'anothersender@example.com'
    }
    result = mailjet.sender.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Sender
        mr := &Request{
          Resource: "sender",
        }
        fmr := &FullRequest{
          Info: mr,
          Payload: &resources.Sender {
          Email: "anothersender@example.com",
        },
        }
        err := mailjetClient.Post(fmr, &data)
        if err != nil {
          fmt.Println(err)
        }
        fmt.Printf("Data array: %+v\n", data)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Sender;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Sender.resource)
                .property(Sender.EMAIL, "anothersender@example.com");
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// Create : Manage an email sender for a single API key. An e-mail address or a complete domain (*) has to be registered and validated before being used to send e-mails. In order to manage a sender available across multiple API keys, see the related MetaSender resource.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Sender.Resource,
             }
                .Property(Sender.Email, "anothersender@example.com");
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    To create a sender, provide the email address of the sender as part of a POST on the resource /sender.

    A verification email will be sent to the address you added to activate this new sender.

    Setup SPF/DKIM on DNS

    To increase the deliverability of your emails, don't forget to properly setup your DNS record.

    You can either visit the Mailjet user interface, or use the Domains and DNS API guide to set up SPF and DKIM.

    Send API v3.1

    Send API v3.1 has been released on August 2017 bringing new functionalities, better error reporting and top-notch developer experience. Mailjet is still supporting Send API V3.

    If you are a current user of Send API in version 3, we listed the changes you will need to take into account to migrate to v3.1.

    Read this blogpost to learn more on how we designed our Send API V3.1 and where our Transactional Suite is going to.

    Send a basic email

    <?php
    /*
    This call sends a message to one recipient.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to one recipient.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to one recipient.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to one recipient.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />May the delivery force be with you!'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to one recipient.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to one recipient.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to one recipient.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to one recipient.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    The Send API v3.1 sends a collection of messages, added in JSON array, called Messages. The input payload must start with Messages array. The mandatory properties for any message element are:

    One of the following content parts is also mandatory :

    API response

    
    {
      "Messages": [
        {
          "Status": "success",
          "To": [
            {
            "Email": "passenger1@mailjet.com",
            "MessageUUID": "123",
            "MessageID": 456,
            "MessageHref": "https://api.mailjet.com/v3/message/456"
            }
          ]
         }
      ]
    }
    

    Send API will send a response containing an array of Messages. Each instance of the message object will include the Status and the list of message UUIDs for each recipient in To, Cc and Bcc.

    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.

    MessageHref is a URL, pointing to the API URL, where the message metadata can be retrieved. It is made of the API Base URL, the message resource path and the message ID (not UUID).

    <?php
    /*
    This call sends a message to one recipient.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ],
                    [
                        'Email' => "passenger2@mailjet.com",
                        'Name' => "passenger 2"
                    ]
                ],
                'Cc' => [
                    [
                        'Email' => "copilot@mailjet.com",
                        'Name' => "Copilot"
                    ]
                ],
                'Bcc' => [
                    [
                        'Email' => "air-traffic-control@mailjet.com",
                        'Name' => "Air traffic control"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to one recipient.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    },
                                    {
                                            "Email": "passenger2@mailjet.com",
                                            "Name": "passenger 2"
                                    }
                            ],
                            "Cc": [
                                    {
                                            "Email": "copilot@mailjet.com",
                                            "Name": "Copilot"
                                    }
                            ],
                            "Bcc": [
                                    {
                                            "Email": "air-traffic-control@mailjet.com",
                                            "Name": "Air traffic control"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to one recipient.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    },
                                    {
                                            "Email": "passenger2@mailjet.com",
                                            "Name": "passenger 2"
                                    }
                            ],
                            "Cc": [
                                    {
                                            "Email": "copilot@mailjet.com",
                                            "Name": "Copilot"
                                    }
                            ],
                            "Bcc": [
                                    {
                                            "Email": "air-traffic-control@mailjet.com",
                                            "Name": "Air traffic control"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to one recipient.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            },
            {
                'Email'=> 'passenger2@mailjet.com',
                'Name'=> 'passenger 2'
            }
        ],
        'Cc'=> [
            {
                'Email'=> 'copilot@mailjet.com',
                'Name'=> 'Copilot'
            }
        ],
        'Bcc'=> [
            {
                'Email'=> 'air-traffic-control@mailjet.com',
                'Name'=> 'Air traffic control'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />May the delivery force be with you!'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to one recipient.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    },
                                    {
                                            "Email": "passenger2@mailjet.com",
                                            "Name": "passenger 2"
                                    }
                            ],
                            "Cc": [
                                    {
                                            "Email": "copilot@mailjet.com",
                                            "Name": "Copilot"
                                    }
                            ],
                            "Bcc": [
                                    {
                                            "Email": "air-traffic-control@mailjet.com",
                                            "Name": "Air traffic control"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to one recipient.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
              mailjet.RecipientV31 {
                Email: "passenger2@mailjet.com",
                Name: "passenger 2",
              },
            },
            Cc: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "copilot@mailjet.com",
                Name: "Copilot",
              },
            },
            Bcc: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "air-traffic-control@mailjet.com",
                Name: "Air traffic control",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to one recipient.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1"))
                            .put(new JSONObject()
                                .put("Email", "passenger2@mailjet.com")
                                .put("Name", "passenger 2")))
                        .put(Emailv31.Message.CC, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "copilot@mailjet.com")
                                .put("Name", "Copilot")))
                        .put(Emailv31.Message.BCC, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "air-traffic-control@mailjet.com")
                                .put("Name", "Air traffic control")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to one recipient.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       },
                      new JObject {
                       {"Email", "passenger2@mailjet.com"},
                       {"Name", "passenger 2"}
                       }
                      }},
                     {"Cc", new JArray {
                      new JObject {
                       {"Email", "copilot@mailjet.com"},
                       {"Name", "Copilot"}
                       }
                      }},
                     {"Bcc", new JArray {
                      new JObject {
                       {"Email", "air-traffic-control@mailjet.com"},
                       {"Name", "Air traffic control"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    API response

    {
      "Messages": [
        {
        "Status": "success",
        "To": [
            {
            "Email": "passenger1@mailjet.com",
            "MessageUUID": "123",
            "MessageID": 456,
            "MessageHref": "https://api.mailjet.com/v3/message/456"
            },
            {
            "Email": "passenger2@mailjet.com",
            "MessageUUID": "124",
            "MessageID": 457,
            "MessageHref": "https://api.mailjet.com/v3/message/457"
            }
          ],
        "Cc": [
            {
            "Email": "copilot@mailjet.com",
            "MessageUUID": "125",
            "MessageID": 458,
            "MessageHref": "https://api.mailjet.com/v3/message/458"
            }
          ],
        "Bcc": [
            {
            "Email": "air-traffic-control@mailjet.com",
            "MessageUUID": "126",
            "MessageID": 459,
            "MessageHref": "https://api.mailjet.com/v3/message/459"
            }
          ]
        }
      ]
    }
    

    Send with attached files

    <?php
    /*
    This call sends a message to the given recipient with attachment.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                'Attachments' => [
                    [
                        'ContentType' => "text/plain",
                        'Filename' => "test.txt",
                        'Base64Content' => "VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK"
                    ]
                ]
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to the given recipient with attachment.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "Attachments": [
                                    {
                                            "ContentType": "text/plain",
                                            "Filename": "test.txt",
                                            "Base64Content": "VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK"
                                    }
                            ]
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to the given recipient with attachment.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "Attachments": [
                                    {
                                            "ContentType": "text/plain",
                                            "Filename": "test.txt",
                                            "Base64Content": "VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK"
                                    }
                            ]
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to the given recipient with attachment.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />May the delivery force be with you!',
        'Attachments'=> [
            {
                'ContentType'=> 'text/plain',
                'Filename'=> 'test.txt',
                'Base64Content'=> 'VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK'
            }
        ]
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to the given recipient with attachment.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "Attachments": [
                                    {
                                            "ContentType": "text/plain",
                                            "Filename": "test.txt",
                                            "Base64Content": "VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK"
                                    }
                            ]
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to the given recipient with attachment.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
            Attachments: &mailjet.AttachmentsV31{
              mailjet.AttachmentV31 {
                ContentType: "text/plain",
                Filename: "test.txt",
                Base64Content: "VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK",
              },
            },
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to the given recipient with attachment.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!")
                        .put(Emailv31.Message.ATTACHMENTS, new JSONArray()
                            .put(new JSONObject()
                                .put("ContentType", "text/plain")
                                .put("Filename", "test.txt")
                                .put("Base64Content", "VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK")))));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to the given recipient with attachment.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"},
                     {"Attachments", new JArray {
                      new JObject {
                       {"ContentType", "text/plain"},
                       {"Filename", "test.txt"},
                       {"Base64Content", "VGhpcyBpcyB5b3VyIGF0dGFjaGVkIGZpbGUhISEK"}
                       }
                      }}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    To attach files, use the properties Attachments or InlinedAttachments.
    When using Attachments, the attachment will be separately added as a file and the recipient should click on it in order to see it. Normally, the inlined attachment(s) should be visible directly in the body of the message, but this depends on the recipient's email client behavior. In both calls, the content needs to be Base64 encoded. You also need to specify the MIME type and a file name.

    <?php
    /*
    This call sends a message to the given recipient with inline attachment.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <img src=\"cid:id1\"> <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                'InlinedAttachments' => [
                    [
                        'ContentType' => "image/png",
                        'Filename' => "logo.png",
                        'ContentID' => "id1",
                        'Base64Content' => "iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg=="
                    ]
                ]
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to the given recipient with inline attachment.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <img src=\"cid:id1\"> <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "InlinedAttachments": [
                                    {
                                            "ContentType": "image/png",
                                            "Filename": "logo.png",
                                            "ContentID": "id1",
                                            "Base64Content": "iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg=="
                                    }
                            ]
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to the given recipient with inline attachment.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <img src=\"cid:id1\"> <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "InlinedAttachments": [
                                    {
                                            "ContentType": "image/png",
                                            "Filename": "logo.png",
                                            "ContentID": "id1",
                                            "Base64Content": "iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg=="
                                    }
                            ]
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to the given recipient with inline attachment.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <img src=\'cid:id1\'> <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />May the delivery force be with you!',
        'InlinedAttachments'=> [
            {
                'ContentType'=> 'image/png',
                'Filename'=> 'logo.png',
                'ContentID'=> 'id1',
                'Base64Content'=> 'iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg=='
            }
        ]
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to the given recipient with inline attachment.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <img src=\"cid:id1\"> <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "InlinedAttachments": [
                                    {
                                            "ContentType": "image/png",
                                            "Filename": "logo.png",
                                            "ContentID": "id1",
                                            "Base64Content": "iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg=="
                                    }
                            ]
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to the given recipient with inline attachment.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <img src=\"cid:id1\"> <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
            InlinedAttachments: &mailjet.InlinedAttachmentsV31{
              mailjet.InlineAttachmentV31 {
                ContentType: "image/png",
                Filename: "logo.png",
                ContentID: "id1",
                Base64Content: "iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg==",
              },
            },
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to the given recipient with inline attachment.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <img src=\"cid:id1\"> <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!")
                        .put(Emailv31.Message.INLINEDATTACHMENTS, new JSONArray()
                            .put(new JSONObject()
                                .put("ContentType", "image/png")
                                .put("Filename", "logo.png")
                                .put("ContentID", "id1")
                                .put("Base64Content", "iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg==")))));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to the given recipient with inline attachment.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <img src=\"cid:id1\"> <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"},
                     {"InlinedAttachments", new JArray {
                      new JObject {
                       {"ContentType", "image/png"},
                       {"Filename", "logo.png"},
                       {"ContentID", "id1"},
                       {"Base64Content", "iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wIIChcxurq5eQAAAAd0RVh0QXV0aG9yAKmuzEgAAAAMdEVYdERlc2NyaXB0aW9uABMJISMAAAAKdEVYdENvcHlyaWdodACsD8w6AAAADnRFWHRDcmVhdGlvbiB0aW1lADX3DwkAAAAJdEVYdFNvZnR3YXJlAF1w/zoAAAALdEVYdERpc2NsYWltZXIAt8C0jwAAAAh0RVh0V2FybmluZwDAG+aHAAAAB3RFWHRTb3VyY2UA9f+D6wAAAAh0RVh0Q29tbWVudAD2zJa/AAAABnRFWHRUaXRsZQCo7tInAAABV0lEQVQokaXSPWtTYRTA8d9N7k1zm6a+RG2x+FItgpu66uDQxbFurrr5OQQHR9FZnARB3PwSFqooddAStCBoqmLtS9omx+ESUXuDon94tnP+5+1JYm057GyQjZFP+l+S6G2FzlNe3WHtHc2TNI8zOlUUGLxsD1kDyR+EEQE2P/L8Jm/uk6RUc6oZaYM0JxtnpEX9AGPTtM6w7yzVEb61EaSNn4QD3j5m4QabH6hkVFLSUeqHyCeot0ib6BdNVGscPM/hWWr7S4Tw9TUvbpFUitHTnF6XrS+sL7O6VBSausT0FZonSkb+nZUFFm+z8Z5up5Btr1Lby7E5Zq4yPrMrLR263ZV52g+LvfW3iy6PXubUNVrnhqYNF3bmiZ1i1MmLnL7OxIWh4T+IMpYeRNyrRzyZjWg/ioh+aVgZu4WfXxaixbsRve5fiwb8epTo8+kZjSPFf/sHvgNC0/mbjJbxPAAAAABJRU5ErkJggg=="}
                       }
                      }}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    When using an inlined attachment, it's possible to insert the file inside the HTML code of the email by using cid:FILENAME.EXT, where FILENAME.EXT is the Filename specified in the declaration of the attachment. Optionally, you can set ContentID. It's converted to a Content-ID SMTP header. The value set must be unique - Mailjet isn't enforcing it - among all the inline attachments and can be used to reference the inlined attachment in the message body, using the following syntax in HTML (since plain text messages can not contain images): <img src="cid:myimagecid"/>

    Send in bulk

    <?php
    /*
    This call sends 2 messages to 2 different recipients.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
            ],
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger2@mailjet.com",
                        'Name' => "passenger 2"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends 2 messages to 2 different recipients.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    },
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger2@mailjet.com",
                                            "Name": "passenger 2"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
                    }
            ]
        }'
    
    /**
     *
     * This call sends 2 messages to 2 different recipients.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    },
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger2@mailjet.com",
                                            "Name": "passenger 2"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends 2 messages to 2 different recipients.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />May the delivery force be with you!'
    }, {
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger2@mailjet.com',
                'Name'=> 'passenger 2'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 2, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 2, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br />May the delivery force be with you!'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends 2 messages to 2 different recipients.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
                    },
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger2@mailjet.com",
                                            "Name": "passenger 2"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends 2 messages to 2 different recipients.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
          },
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger2@mailjet.com",
                Name: "passenger 2",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends 2 messages to 2 different recipients.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"))
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger2@mailjet.com")
                                .put("Name", "passenger 2")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends 2 messages to 2 different recipients.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"}
                     },
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger2@mailjet.com"},
                       {"Name", "passenger 2"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    API response:

    {
      "Messages": [
        {
        "Status": "success",
        "To": [
            {
            "Email": "passenger1@mailjet.com",
            "MessageUUID": "123",
            "MessageID": 20547681647433000,
            "MessageHref": "https://api.mailjet.com/v3/message/20547681647433000"
            }
          ]
        },
        {
        "Status": "success",
        "To": [
            {
            "Email": "passenger2@mailjet.com",
            "MessageUUID": "124",
            "MessageID": 20547681647433001,
            "MessageHref": "https://api.mailjet.com/v3/message/20547681647433001"
            }
          ]
        }
      ]
    }
    

    To send messages in bulk, package the multiple messages inside the Messages property.

    The messages’ order is preserved from the user input, allowing you to identify which message response corresponds to your original message payload.

    API response with 1 message in error

    {
        "Messages": [
            {
                "Errors": [
                    {
                        "ErrorIdentifier": "88b5ca9f-5f1f-42e7-a45e-9ecbad0c285e",
                        "ErrorCode": "send-0003",
                        "StatusCode": 400,
                        "ErrorMessage": "At least \"HTMLPart\", \"TextPart\" or \"TemplateID\" must be provided.",
                        "ErrorRelatedTo": [
                            "HTMLPart",
                            "TextPart"
                        ]
                    }
                ],
                "Status": "error"
            },
            {
                "Status": "success",
                "CustomID": "",
                "To": [
                    {
                        "Email": "passenger2@mailjet.com",
                        "MessageUUID": "cb927469-36fd-4c02-bce4-0d199929a207",
                        "MessageID": 70650219165027410,
                        "MessageHref": "https://api.mailjet.com/v3/REST/message/70650219165027410"
                    }
                ],
                "Cc": [],
                "Bcc": []
            }
        ]
    }
    

    In case of errors on one or several of the messages, the API will not stop the processing of other successful messages. All validated messages will be processed for sending and the response will include both MessageIDs and Error reports.

    Personalization

    Content formatting

    Mailjet offers a templating language that allows you to personalize your transactional messages. It enables you to insert data in your text or HTML parts.

    To do so, use {{DATA_TYPE:DATA_NAME}} where:

    Visit our Transactional templating guide to learn about additional substitutions, modification functions and conditional statements you can use to personalize your messages.

    Use vars and custom vars

    <?php
    /*
    This call sends a message to a recipient with global personalisation.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Variables' => [
                    'day' => "Monday"
                ],
                'TemplateLanguage' => true,
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to a recipient with global personalisation.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Variables": {
                                    "day": "Monday"
                            },
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!"
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to a recipient with global personalisation.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Variables": {
                                    "day": "Monday"
                            },
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to a recipient with global personalisation.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Variables'=> {
            'day'=> 'Monday'
        },
        'TemplateLanguage'=> true,
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!'
    }]
    )
    p variable.attributes['Messages']
    
    /*
    This call sends a message to a recipient with global personalisation.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
          Variables: map[string]interface{}{
          "day": "Monday"},
          TemplateLanguage: true,
          Subject: "Your email flight plan!",
        TextPart: "Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!",
        HTMLPart: "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!",
        },
      },
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    """
    This call sends a message to a recipient with global personalisation.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Variables": {
                                    "day": "Monday"
                            },
                            "TemplateLanguage": True,
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to a recipient with global personalisation.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.VARIABLES, new JSONObject()
                            .put("day", "Monday"))
                        .put(Emailv31.Message.TEMPLATELANGUAGE, true)
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to a recipient with global personalisation.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Variables", new JObject {
                      {"day", "Monday"}
                      }},
                     {"TemplateLanguage", true},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger, welcome to Mailjet! On this {{var:day}}, may the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />On this {{var:day}}, may the delivery force be with you!"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    By using Variables in conjunction with the {{var:VAR_NAME}} or {{var:VAR_NAME:DEFAULT_VALUE}} , you can modify the content of your email with variables, pushed in your Send API call.

    DEFAULT_VALUEis the default value that will be used, if the variable is not defined in the API call.

    Use contact properties

    <?php
    /*
    This call sends a message to the a recipient with contact property personalisation.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'TemplateLanguage' => true,
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear {{data:firstname:\"passenger\"}}, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * This call sends a message to the a recipient with contact property personalisation.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear {{data:firstname:\"passenger\"}}, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to the a recipient with contact property personalisation.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'TemplateLanguage'=> true,
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear {{data:firstname:\'passenger\'}}, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear {{data:firstname:\'passenger\'}}, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br /> May the delivery force be with you!'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to the a recipient with contact property personalisation.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TemplateLanguage": True,
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear {{data:firstname:\"passenger\"}}, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to the a recipient with contact property personalisation.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            TemplateLanguage: true,
            Subject: "Your email flight plan!",
          TextPart: "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! May the delivery force be with you!",
          HTMLPart: "<h3>Dear {{data:firstname:\"passenger\"}}, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to the a recipient with contact property personalisation.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.TEMPLATELANGUAGE, true)
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear {{data:firstname:\"passenger\"}}, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to the a recipient with contact property personalisation.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"TemplateLanguage", true},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear {{data:firstname:\"passenger\"}}, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    
    # This call sends a message to the a recipient with contact property personalisation.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear {{data:firstname:\"passenger\"}}, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear {{data:firstname:\"passenger\"}}, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> May the delivery force be with you!"
                    }
            ]
        }'
    

    If the contact you are sending an email to is already existing in the Mailjet system with some contact data, 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.

    Use a Template

    <?php
    /*
    This call sends a message based on a template.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'TemplateID' => 1,
                'TemplateLanguage' => true,
                'Subject' => "Your email flight plan!"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message based on a template.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TemplateID": 1,
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!"
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message based on a template.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TemplateID": 1,
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message based on a template.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'TemplateID'=> 1,
        'TemplateLanguage'=> true,
        'Subject'=> 'Your email flight plan!'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message based on a template.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TemplateID": 1,
                            "TemplateLanguage": True,
                            "Subject": "Your email flight plan!"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message based on a template.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            TemplateID: 1,
            TemplateLanguage: true,
            Subject: "Your email flight plan!",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message based on a template.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.TEMPLATEID, "1")
                        .put(Emailv31.Message.TEMPLATELANGUAGE, true)
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message based on a template.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"TemplateID", 1},
                     {"TemplateLanguage", true},
                     {"Subject", "Your email flight plan!"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Mailjet offers to store your transactional message templates on its platform. You can use these templates to avoid repeating the content of a transactional message at each Send API call.

    You can either create the templates through our online drag and drop tool Passport or through the /template resource.

    You can learn more about storing your templates through API here.

    You can also follow our Step by Step guide to create your first Passport template with templating language.

    In the templates, you will be able to use simple personalization ([[data:property_name]] or [[var:variable_name]]) or advanced templating language ({{data:property_name}}, {{var:variable_name}}, conditional statements and loop statements)

    In this sample, TemplateID will be the ID provided by Passport at the end of your designing process or the ID returned by the /template resource.

    Use Templating Language

    <?php
    /*
    This call sends a message to the given recipient with vars and custom vars.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'TextPart' => "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                'HTMLPart' => "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                'TemplateLanguage' => true,
                'Subject' => "Your email flight plan!",
                'Variables' => [
                    'day' => "Tuesday",
                    'personalmessage' => "Happy birthday!"
                ]
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to the given recipient with vars and custom vars.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TextPart": "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                            "HTMLPart": "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!",
                            "Variables": {
                                    "day": "Tuesday",
                                    "personalmessage": "Happy birthday!"
                            }
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to the given recipient with vars and custom vars.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TextPart": "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                            "HTMLPart": "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                            "TemplateLanguage": true,
                            "Subject": "Your email flight plan!",
                            "Variables": {
                                    "day": "Tuesday",
                                    "personalmessage": "Happy birthday!"
                            }
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to the given recipient with vars and custom vars.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'TextPart'=> 'Dear passenger, welcome to Mailjet! On this {{var:day:\'monday\'}}, may the delivery force be with you! {{var:personalmessage:\'\'}}',
        'HTMLPart'=> '<h3>Dear passenger, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br /> On this {{var:day:\'monday\'}}, may the delivery force be with you! {{var:personalmessage:\'\'}}',
        'TemplateLanguage'=> true,
        'Subject'=> 'Your email flight plan!',
        'Variables'=> {
            'day'=> 'Tuesday',
            'personalmessage'=> 'Happy birthday!'
        }
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to the given recipient with vars and custom vars.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "TextPart": "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                            "HTMLPart": "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
                            "TemplateLanguage": True,
                            "Subject": "Your email flight plan!",
                            "Variables": {
                                    "day": "Tuesday",
                                    "personalmessage": "Happy birthday!"
                            }
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to the given recipient with vars and custom vars.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
          TextPart: "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
          HTMLPart: "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
            TemplateLanguage: true,
            Subject: "Your email flight plan!",
          Variables: map[string]interface{}{
          "day": "Tuesday""personalmessage": "Happy birthday!"},
        },
      },
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to the given recipient with vars and custom vars.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.TEXTPART, "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}")
                        .put(Emailv31.Message.TEMPLATELANGUAGE, true)
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.VARIABLES, new JSONObject()
                            .put("day", "Tuesday")
                            .put("personalmessage", "Happy birthday!"))));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to the given recipient with vars and custom vars.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"TextPart", "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}"},
                     {"HTMLPart", "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}"},
                     {"TemplateLanguage", true},
                     {"Subject", "Your email flight plan!"},
                     {"Variables", new JObject {
                      {"day", "Tuesday"},
                      {"personalmessage", "Happy birthday!"}
                      }}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Mailjet Send API allows you to leverage the Mailjet templating language in your transactional messages.

    The Mailjet Templating Language enables you to achieve:

    Find our dedicated guide here.

    Add Email Headers

    <?php
    /*
    This call sends an email to one recipient with an additional SMTP header
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                'Headers' => [
                    'X-My-header' => "X2332X-324-432-534"
                ]
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends an email to one recipient with an additional SMTP header
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "Headers": {
                                    "X-My-header": "X2332X-324-432-534"
                            }
                    }
            ]
        }'
    
    /**
     *
     * This call sends an email to one recipient with an additional SMTP header
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "Headers": {
                                    "X-My-header": "X2332X-324-432-534"
                            }
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends an email to one recipient with an additional SMTP header
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br />May the delivery force be with you!',
        'Headers'=> {
            'X-My-header'=> 'X2332X-324-432-534'
        }
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends an email to one recipient with an additional SMTP header
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "Headers": {
                                    "X-My-header": "X2332X-324-432-534"
                            }
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends an email to one recipient with an additional SMTP header
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                        .put(Emailv31.Message.HEADERS, new JSONObject()
                            .put("X-My-header", "X2332X-324-432-534"))));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends an email to one recipient with an additional SMTP header
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"},
                     {"Headers", new JObject {
                      {"X-My-header", "X2332X-324-432-534"}
                      }}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    
    /*
    This call sends an email to one recipient with an additional SMTP header
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
          Headers: map[string]interface{}{
          "X-My-header": "X2332X-324-432-534"},
        },
      },
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    

    In every message, you can specify your own Email headers using the Headers property. These headers will be added to the SMTP headers of the message, delivered to the recipient.

    Only headers that don’t have a dedicated property in the message payload can be customized through the Headers property. In addition, some headers can’t be customized.

    List of forbidden headers :

    From Sender Subject To
    Cc Bcc Return-Path Delivered-To
    DKIM-Signature DomainKey-Status Received-SPF Authentication-Results
    Received X-Mailjet-Prio X-Mailjet-Debug User-Agent
    X-Mailer X-MJ-CustomID X-MJ-EventPayload X-MJ-Vars
    X-MJ-TemplateErrorDeliver X-MJ-TemplateErrorReporting X-MJ-TemplateLanguage X-Mailjet-TrackOpen
    X-Mailjet-TrackClick X-MJ-TemplateID X-MJ-WorkflowID X-Feedback-Id
    X-Mailjet-Segmentation List-Id X-MJ-MID X-MJ-ErrorMessage
    Date X-CSA-Complaints Message-Id X-Mailjet-Campaign
    X-MJ-StatisticsContactsListID

    Tag Email Messages

    Mailjet provides 2 properties to tag messages with your own custom information.

    These custom tags are included in the events triggered by our Event API and in the messages processed via our Parse API.

    Send an email with a custom ID

    <?php
    /*
    This call sends a message to one recipient with a CustomID
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                'CustomID' => "PassengerEticket1234"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to one recipient with a CustomID
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "CustomID": "PassengerEticket1234"
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to one recipient with a CustomID
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "CustomID": "PassengerEticket1234"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to one recipient with a CustomID
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br />May the delivery force be with you!',
        'CustomID'=> 'PassengerEticket1234'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to one recipient with a CustomID
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "CustomID": "PassengerEticket1234"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to one recipient with a CustomID
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
            CustomID: "PassengerEticket1234",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to one recipient with a CustomID
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                        .put(Emailv31.Message.CUSTOMID, "PassengerEticket1234")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to one recipient with a CustomID
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"},
                     {"CustomID", "PassengerEticket1234"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Sometimes you may need to use your own ID, in addition to ours, to be able to easily trace back the message in our system. To achieve this, just pass the ID you wish in the CustomID property.

    # View : API Key Statistical campaign/message data.
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/message?CustomID=PassengerEticket1234 
    
    <?php
    /*
    View : API Key Statistical campaign/message data.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'CustomID' => 'PassengerEticket1234'
    ];
    $response = $mj->get(Resources::$Message, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * View : API Key Statistical campaign/message data.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("message")
        .request({
            "CustomID":"PassengerEticket1234"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : API Key Statistical campaign/message data.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Message.all(custom_id: "PassengerEticket1234"
    )
    p variable.attributes['Data']
    
    """
    View : API Key Statistical campaign/message data.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    filters = {
      'CustomID': 'PassengerEticket1234'
    }
    result = mailjet.message.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    View : API Key Statistical campaign/message data.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Message
        _, _, err := mailjetClient.List("message", &data, Filter("CustomID", "PassengerEticket1234"))
        if err != nil {
          fmt.Println(err)
        }
        fmt.Printf("Data array: %+v\n", data)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Message;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : API Key Statistical campaign/message data.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Message.resource)
                      .filter(Message.CUSTOMID, "PassengerEticket1234");
          response = client.get(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// View : API Key Statistical campaign/message data.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Message.Resource,
             }
             .Filter(Message.Customid, "PassengerEticket1234");
             MailjetResponse response = await client.GetAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Your CustomID will be linked to our own UUID. You can also retrieve the message later by providing it to the /message resource with CustomID filter.

    Send an email with a payload

    <?php
    /*
    This call sends a message to one recipient with an EventPayload.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                'EventPayload' => "Eticket,1234,row,15,seat,B"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to one recipient with an EventPayload.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "EventPayload": "Eticket,1234,row,15,seat,B"
                    }
            ]
        }'
    
    # This call sends a message to one recipient with an EventPayload.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br />May the delivery force be with you!',
        'EventPayload'=> 'Eticket,1234,row,15,seat,B'
    }]
    )
    p variable.attributes['Messages']
    
    /**
     *
     * This call sends a message to one recipient with an EventPayload.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "EventPayload": "Eticket,1234,row,15,seat,B"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    """
    This call sends a message to one recipient with an EventPayload.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "EventPayload": "Eticket,1234,row,15,seat,B"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to one recipient with an EventPayload.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
            EventPayload: "Eticket,1234,row,15,seat,B",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to one recipient with an EventPayload.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                        .put(Emailv31.Message.EVENTPAYLOAD, "Eticket,1234,row,15,seat,B")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to one recipient with an EventPayload.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"},
                     {"EventPayload", "Eticket,1234,row,15,seat,B"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Sometimes, you need more than just an ID to represent the context of a specific message. For this purpose, we let you insert a payload in the message which can be of any format (XML, JSON, CSV, etc). To take advantage of this, just pass the payload you want in the EventPayload property.

    Group into a campaign

    <?php
    /*
    This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                'CustomCampaign' => "SendAPI_campaign",
                'DeduplicateCampaign' => true
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "CustomCampaign": "SendAPI_campaign",
                            "DeduplicateCampaign": true
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "CustomCampaign": "SendAPI_campaign",
                            "DeduplicateCampaign": true
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!</h3><br />May the delivery force be with you!',
        'CustomCampaign'=> 'SendAPI_campaign',
        'DeduplicateCampaign'=> true
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "CustomCampaign": "SendAPI_campaign",
                            "DeduplicateCampaign": True
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!",
            CustomCampaign: "SendAPI_campaign",
            DeduplicateCampaign: true,
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!")
                        .put(Emailv31.Message.CUSTOMCAMPAIGN, "SendAPI_campaign")
                        .put(Emailv31.Message.DEDUPLICATECAMPAIGN, true)));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to one recipient within a campaign blocking multiple messages to same recipient
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"},
                     {"CustomCampaign", "SendAPI_campaign"},
                     {"DeduplicateCampaign", true}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Messages sent through Send API can be regrouped into campaigns to simulate the behavior of a regular marketing campaign. This could help you with pulling advanced statistics for your transactional campaigns.

    Use the Property CustomCampaign to specify the name of the campaign the message will be classified in. If the campaign doesn't already exist, it will be automatically created in the Mailjet system.

    By default, Mailjet lets you send multiple emails with the same campaign to the same contact. To block this feature, use DeduplicateCampaign with the value 1 to stop contacts from being emailed several times in the same campaign.

    Add URL tags

    <?php
    /*
    This calls sends an email to one recipient.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"http://www.mailjet.com\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                'URLTags' => "param1=1&param2=2"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This calls sends an email to one recipient.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"http://www.mailjet.com\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "URLTags": "param1=1&param2=2"
                    }
            ]
        }'
    
    /**
     *
     * This calls sends an email to one recipient.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"http://www.mailjet.com\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "URLTags": "param1=1&param2=2"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This calls sends an email to one recipient.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'http://www.mailjet.com\'>Mailjet</a>!</h3><br />May the delivery force be with you!',
        'URLTags'=> 'param1=1&param2=2'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This calls sends an email to one recipient.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"http://www.mailjet.com\">Mailjet</a>!</h3><br />May the delivery force be with you!",
                            "URLTags": "param1=1&param2=2"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This calls sends an email to one recipient.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"http://www.mailjet.com\">Mailjet</a>!</h3><br />May the delivery force be with you!",
            URLTags: "param1=1&param2=2",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This calls sends an email to one recipient.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"http://www.mailjet.com\">Mailjet</a>!</h3><br />May the delivery force be with you!")
                        .put(Emailv31.Message.URLTAGS, "param1=1&param2=2")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This calls sends an email to one recipient.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"http://www.mailjet.com\">Mailjet</a>!</h3><br />May the delivery force be with you!"},
                     {"URLTags", "param1=1&param2=2"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    If you need to add tracking parameters in all your URLS in one simple way in your message, Send API offers the URLTags property. This solution will be perfect for passing UTM parameters for your traffic analytics in a easy way, without having to modify every single URLs in your message yourself.

    You just need to provide the query part between the first "?" character and "#" character.

    So if you want to have a URL in this format: http://www.example.com?param1=1&param2=2

    You will just need to specify : "URLTags":"param1=1&param2=2"

    In your HTMLPart or template, you will only need to specify the href http://www.example.com.

    Mailjet will add the parameters in all of the URLs in your message, before adding the Mailjet click tracking and sending the message. The URLs in your click statistics will include the URLTags provided.

    Sandbox Mode

    <?php
    /*
    This call sends a message to one recipient in sandbox mode.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
            ]
        ],
        'SandboxMode' => true
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to one recipient in sandbox mode.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
                    }
            ],
            "SandboxMode":true
        }'
    
    /**
     *
     * This call sends a message to one recipient in sandbox mode.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
                    }
            ],
            "SandboxMode":true
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to one recipient in sandbox mode.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br />May the delivery force be with you!'
    }],
    sandbox_mode: true
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to one recipient in sandbox mode.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
                    }
            ],
      'SandboxMode': True
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to one recipient in sandbox mode.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo, SandboxMode: true }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to one recipient in sandbox mode.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")))
                .property(Emailv31.SANDBOXMODE, true);
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to one recipient in sandbox mode.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"}
                     }
                    })
                .Property(Send.SandboxMode, true);
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    API response:

    {
      "Messages": [
        {
          "Status": "success",
          "CustomID": "",
          "To": [
            {
              "Email": "passenger1@mailjet.com",
              "MessageUUID": "",
              "MessageID": 0,
              "MessageHref": "https://api.mailjet.com/v3/message/0"
            }
          ],
          "Cc": [],
          "Bcc": []
        }
      ]
    }
    

    The Send API v3.1 allows to run the API call in a Sandbox mode, where all validations of the payload will be done without delivering the message.

    By setting the SandboxMode property to a true value, you will turn off the delivery of the message while still getting back the full range of error messages that could be related to your message processing. If the message is processed without error, the response will follow the normal response payload format, omitting only the MessageID and MessageUUID.

    Real-time Monitoring

    <?php
    /*
    This call sends a message to one recipient with Real-time Monitoring.
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);
    $body = [
        'Messages' => [
            [
                'From' => [
                    'Email' => "pilot@mailjet.com",
                    'Name' => "Mailjet Pilot"
                ],
                'To' => [
                    [
                        'Email' => "passenger1@mailjet.com",
                        'Name' => "passenger 1"
                    ]
                ],
                'Subject' => "Your email flight plan!",
                'TextPart' => "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                'MonitoringCategory' => "Category1"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This call sends a message to one recipient with Real-time Monitoring.
    curl -s \
        -X POST \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3.1/send \
        -H 'Content-Type: application/json' \
        -d '{
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "MonitoringCategory": "Category1"
                    }
            ]
        }'
    
    /**
     *
     * This call sends a message to one recipient with Real-time Monitoring.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send", {'version': 'v3.1'})
        .request({
            "Messages":[
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "MonitoringCategory": "Category1"
                    }
            ]
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This call sends a message to one recipient with Real-time Monitoring.
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
      config.api_version = "v3.1"
    end
    variable = Mailjet::Send.create(messages: [{
        'From'=> {
            'Email'=> 'pilot@mailjet.com',
            'Name'=> 'Mailjet Pilot'
        },
        'To'=> [
            {
                'Email'=> 'passenger1@mailjet.com',
                'Name'=> 'passenger 1'
            }
        ],
        'Subject'=> 'Your email flight plan!',
        'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',
        'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\'https://www.mailjet.com/\'>Mailjet</a>!<br />May the delivery force be with you!',
        'MonitoringCategory'=> 'Category1'
    }]
    )
    p variable.attributes['Messages']
    
    """
    This call sends a message to one recipient with Real-time Monitoring.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret), version='v3.1')
    data = {
      'Messages': [
                    {
                            "From": {
                                    "Email": "pilot@mailjet.com",
                                    "Name": "Mailjet Pilot"
                            },
                            "To": [
                                    {
                                            "Email": "passenger1@mailjet.com",
                                            "Name": "passenger 1"
                                    }
                            ],
                            "Subject": "Your email flight plan!",
                            "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
                            "HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
                            "MonitoringCategory": "Category1"
                    }
            ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This call sends a message to one recipient with Real-time Monitoring.
    */
    package main
    import (
        "fmt"
        "log"
        "os"
        mailjet "github.com/mailjet/mailjet-apiv3-go"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        messagesInfo := []mailjet.InfoMessagesV31 {
          mailjet.InfoMessagesV31{
            From: &mailjet.RecipientV31{
              Email: "pilot@mailjet.com",
              Name: "Mailjet Pilot",
            },
            To: &mailjet.RecipientsV31{
              mailjet.RecipientV31 {
                Email: "passenger1@mailjet.com",
                Name: "passenger 1",
              },
            },
            Subject: "Your email flight plan!",
            TextPart: "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
            HTMLPart: "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
            MonitoringCategory: "Category1",
          },
        }
        messages := mailjet.MessagesV31{Info: messagesInfo }
        res, err := m.SendMailV31(&messages)
        if err != nil {
            log.Fatal(err)
        }
        fmt.Printf("Data: %+v\n", res)
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.ClientOptions;
    import com.mailjet.client.resource.Emailv31;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This call sends a message to one recipient with Real-time Monitoring.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"), new ClientOptions("v3.1"));
          request = new MailjetRequest(Emailv31.resource)
                .property(Emailv31.MESSAGES, new JSONArray()
                    .put(new JSONObject()
                        .put(Emailv31.Message.FROM, new JSONObject()
                            .put("Email", "pilot@mailjet.com")
                            .put("Name", "Mailjet Pilot"))
                        .put(Emailv31.Message.TO, new JSONArray()
                            .put(new JSONObject()
                                .put("Email", "passenger1@mailjet.com")
                                .put("Name", "passenger 1")))
                        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
                        .put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
                        .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                        .put(Emailv31.Message.MONITORINGCATEGORY, "Category1")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This call sends a message to one recipient with Real-time Monitoring.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"))
             {
                Version = ApiVersion.V3_1,
             };
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.Messages, new JArray {
                    new JObject {
                     {"From", new JObject {
                      {"Email", "pilot@mailjet.com"},
                      {"Name", "Mailjet Pilot"}
                      }},
                     {"To", new JArray {
                      new JObject {
                       {"Email", "passenger1@mailjet.com"},
                       {"Name", "passenger 1"}
                       }
                      }},
                     {"Subject", "Your email flight plan!"},
                     {"TextPart", "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"},
                     {"HTMLPart", "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"},
                     {"MonitoringCategory", "Category1"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(response.GetData());
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    Real-time Monitoring enables you to have a constant supervision on your transactional messages by creating custom alerts on categories of Messages.

    You can create as many alerts as you want under one of our four types of monitoring alerts, allowing you to fully control your sending:

    Mailjet’s Real-time monitoring will inform you by email, Slack or even SMS based on the alert configuration.

    After creating your categories and alerts in our user interface, you can leverage the MonitoringCategory property to specify which category the message you are sending is related to.

    Learn more about Mailjet Real-time Monitoring.

    Send API JSON properties

    Payload property

    The Send API payload will contain only one property Messages, which is a collection of messages, represented as a JSON array.

    Message JSON properties

    Each message will be described with the following properties.

    Property Name Description
    From Must be a valid, activated and registered sender for this account
    JSON object with 2 properties Email and Name
    Sample : {"Email": "pilot@mailjet.com", "Name":"your pilot speaking"}
    Sender It applies only on a given API Key. Contact the support team if you want us to enable this setting for the whole account.
    Must be a valid active sender for this account.
    Perform a simple GET on resource /sender to view a list of allowed senders for your account, or within the Mailjet Account Settings under Sender Addresses
    JSON object with 2 properties Email and Name
    Sample : {"Email": "pilot@mailjet.com", "Name":"your pilot speaking"}
    To Collection of recipients, each presented as a JSON object
    Sample: [{"Email":"passenger@mailjet.com","Name":"passenger"}]
    If a recipient is specified twice (in the to, cc, or bcc), it is counted only once.
    Can be a contact list as well (magic list) - address@lists.mailjet.com. See the Address contactslist property.
    MAX RECIPIENTS: 50
    Cc, Bcc Collection of carbon copy and blind carbon copy recipients, each presented as a JSON object
    Sample: [{"Email":"passenger@mailjet.com","Name":"passenger"}]
    If one recipient is specified twice, we count it as one (including to, cc, bcc)
    MAX RECIPIENTS: 50
    ReplyTo Reply to address for the message
    Email address, where the replies go to. JSON object with 2 properties Email and Name
    Sample : {"Email": "pilot@mailjet.com", "Name":"your pilot listening"}
    Subject Maximum length is 255 chars
    MAX SUBJECTS: 1
    TextPart Provides the Text part of the message
    Mandatory if the HTML or TemplateID parameter is not specified
    MANDATORY IF NO HTML - MAX PARTS: 1
    HTMLPart Provides the HTML part of the message
    Mandatory if the Text or TemplateID parameter is not specified
    MANDATORY IF NO TEXT - MAX PARTS: 1
    TemplateID The Template ID to be used as email content. Overrides the HTML/Text parts if any.
    Equivalent to using the X-MJ-TemplateID header through SMTP.
    MANDATORY IF NO HTML/TEXT - MAX TEMPLATEID: 1
    TemplateLanguage Activates the template language processing. By default the template language processing is deactivated. Use True to activate.
    Equivalent to using the X-MJ-TemplateLanguage header through SMTP.
    More information
    TemplateErrorReporting Recipient address where template language error reports will be delivered. Can only be set when TemplateLanguage is true. Format: {Email, Name}
    Equivalent to using the X-MJ-TemplateErrorReporting header through SMTP.
    More information
    TemplateErrorDeliver Boolean flag, determining whether the message should be delivered in case of an error while executing the template language. Can only be set when TemplateLanguage is true
    Equivalent to using the X-MJ-TemplateErrorDeliver header through SMTP.
    More information
    Attachments Attach files automatically to this Email
    Size of all attachments, including inline may not exceed 15 MB total
    Sample: [{"ContentType": "MIME TYPE", "Filename": "FILENAME.EXT", "Base64Content":"BASE64 ENCODED CONTENT"}]
    InlinedAttachments Attach a file for inline use via cid:ID_FOR_HTML
    Size of all attachments, including inline must not exceed 15 MB total
    Sample: [{"ContentType": "MIME TYPE", "Filename": "FILENAME.EXT", "Base64Content":"BASE64 ENCODED CONTENT, "ContentID":"ID_FOR_HTML"}]
    Priority Manage message processing priority inside your account's (API key) scheduling queue.
    Equivalent of using X-Mailjet-Prio header through SMTP
    More information
    CustomCampaign Groups multiple messages in one campaign
    Equivalent of using X-Mailjet-Campaign header through SMTP.
    More information
    DeduplicateCampaign Block/unblock messages to be sent multiple times inside one campaign to the same contact.
    - false: unblocked (default behaviour)
    - true: blocked
    Equivalent of using X-Mailjet-DeduplicateCampaign header through SMTP.
    Can only be used if CustomCampaign is specified.
    More information
    TrackOpens Force or disable open tracking on this message, can override account preferences.
    Can only be used with a HTML part.
    Accepts 3 values: account_default , disabled , enabled . Equivalent to X-Mailjet-TrackOpen SMTP custom header (despite the different format)
    TrackClicks Force or disable click tracking on this message, can override account preferences.
    Can only be specified if the HTML part is provided.
    Accepts 3 values: account_default , disabled , enabled . Equivalent to X-Mailjet-TrackOpen SMTP custom header (despite the different format)
    CustomID Attach a custom ID to the message
    Equivalent to using the X-MJ-CustomID header through SMTP.
    More information
    EventPayload Attach a payload to the message
    Equivalent to using the X-MJ-EventPayload header through SMTP.
    More information
    MonitoringCategory Category for Real-time Monitoring to which the message will be attached
    URLTags URL parameters to append to all your URLs. A maximum length of 256 characters is allowed per message.
    Headers Add lines to the email's headers
    List of headers as "property":"value" pairs
    Notice: overriding values of header properties (ie: subject)
    Sample: {"X-My-Header":"my own value","X-My-Header-2":"my own value 2"}
    Variables Variables used for personalization and/or template language in the message
    Equivalent of using X-MJ-Vars header through SMTP.

    Send API errors

    Global Error (example: broken JSON format)

    {
      "ErrorIdentifier": "06df1144-c6f3-4ca7-8885-7ec5d4344113",
      "ErrorCode": "mj-0002",
      "ErrorMessage": "Malformed JSON, please review the syntax and properties types.",
      "StatusCode": 400
    }
    

    Error in validation of the JSON Payload

    {
      "Messages":[
        {
          "Status": "error",
          "Errors": [
            {
              "ErrorIdentifier": "f987008f-251a-4dff-8ffc-40f1583ad7bc",
              "ErrorCode": "mj-0004",
              "StatusCode": 400,
              "ErrorMessage": "Type mismatch. Expected type \"array of emails\".",
              "ErrorRelatedTo": ["HTMLPart", "TemplateID"]
            },
            {
              "ErrorIdentifier": "8e28ac9c-1fd7-41ad-825f-1d60bc459189",
              "ErrorCode": "mj-0005",
              "StatusCode": 400,
              "ErrorMessage": "The To is mandatory but missing from the input",
              "ErrorRelatedTo": ["To"]
            }
          ]
        }
      ]
    }
    

    When an error occurs on a message validation, a error Status will be returned in the response. The description of the error(s) will be contain in the Errors property. Each error will contain the following properties:

    In bulk sending (multiple instances of messages in Messages), we will process each message separately. As a result, the response can contain both success and error notifications. For a single message, Send API can return multiple errors, each related to different properties of the payload.

    Status Code Error Code Description Related To
    400 send-0003 when none of the HTML, Text, TemplateID properties are provided. HTMLPart, TextPart, TemplateID
    400 send-0004 when providing HTML property, as well as a template also containing an HTML part - i.e. Duplicated content HTMLPart, TemplateID
    403 send-0006 when the API key doesn’t have permission to use a Sender header. Please contact our support team to be granted permission. SenderID
    403 send-0007 when SenderID is provided but not validated. SenderID
    403 send-0008 when the sender email address provided in the From property is not authorized. The validation can be done on the Sender domains & addresses page or through the API. From
    400 send-0010 when the API key can’t send the provided template. Please verify the owner of the template. TemplateID
    400 send-0011 when one of the forbidden headers (headers that have a property alternative) is set in the Headers collection. Please use the dedicated message property to set this header. Headers["headerName"]
    400 send-0012 when DeduplicateCampaign is set to true while no CustomCampaign is defined. CustomCampaign, DeduplicateCampaign
    400 send-0013 when MonitoringCategory does not exist for the API key. MonitoringCategory
    400 send-0015 when the total number of recipients is over the limit. To,CC,Bcc
    400 send-0016 when TemplateLanguage value is missing but TemplateErrorReporting or TemplateErrorDeliver are present. TemplateLanguage
    401 mj-0001 when API key is suspended.
    400 mj-0002 when the API call contains payload with an invalid JSON syntax.
    400 mj-0003 when mandatory property is missing or with null value. See ErrorRelatedTo for a list
    400 mj-0005 when a property value is not an allowed values. Priority
    TrackClicks
    TrackOpens
    400 mj-0006 when a property contains more than the maximum allowed number of characters. Subject
    URLTags
    400 mj-0007 when an empty array is provided that cannot be empty. Messages
    To
    400 mj-0008 when an array property contains more than the maximum allowed number of elements. Messages
    Attachments
    InlineAttachments
    Headers
    Variables
    400 mj-0011 when the payload size is over the limit.
    400 mj-0012 when an empty string value is provided. Email
    FileName
    Base64Content
    ContentType
    400 mj-0013 when the email address format is invalid. Email
    401 mj-0015 when the user did not provide valid authorization credentials.

    When the HTTP status for the API call is 500, you will see ErrorIdentifier field. It will contain a reference to the error in our internal log and it is crucial for us to determine the root cause of the failure. Should you encounter such errors, please contact our support for additional investigation, providing this error identifier.

    Send API v3

    Send a basic email

    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    data = {
        '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'}]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This calls sends an email to one recipient.
    */
    package main
    import (
        "fmt"
        . "github.com/mailjet/mailjet-apiv3-go"
        "os"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        email := &InfoSendMail {
          FromEmail: "pilot@mailjet.com",
          FromName: "Mailjet Pilot",
          Subject: "Your email flight plan!",
          TextPart: "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
          HTMLPart: "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
          Recipients: []Recipient {
            Recipient {
              Email: "passenger@mailjet.com",
            },
          },
        }
        res, err := mailjetClient.SendMail(email)
        if err != nil {
                fmt.Println(err)
        } else {
                fmt.Println("Success")
                fmt.Println(res)
        }
    }
    
    <?php
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $body = [
        '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"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']
      config.default_from = 'your default sending address'
    end
    variable = Mailjet::Send.create(
            from_email: "pilot@mailjet.com",
            from_name: "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'}])
    
    package MyClass;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Email;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This calls sends an email to one recipient.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Email.resource)
                            .property(Email.FROMEMAIL, "pilot@mailjet.com")
                            .property(Email.FROMNAME, "Mailjet Pilot")
                            .property(Email.SUBJECT, "Your email flight plan!")
                            .property(Email.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
                            .property(Email.HTMLPART, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                            .property(Email.RECIPIENTS, new JSONArray()
                    .put(new JSONObject()
                        .put("Email", "passenger@mailjet.com")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    # This calls 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"}]
        }'
    
    /**
     *
     * This calls sends an email to one recipient.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send")
        .request({
            "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"}]
        })
    request
        .then(result => {
            console.log(result.body)
        })
        .catch(err => {
            console.log(err.statusCode)
        })
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This calls sends an email to one recipient.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.FromEmail, "pilot@mailjet.com")
                .Property(Send.FromName, "Mailjet Pilot")
                .Property(Send.Subject, "Your email flight plan!")
                .Property(Send.TextPart, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
                .Property(Send.HtmlPart, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                .Property(Send.Recipients, new JArray {
                    new JObject {
                     {"Email", "passenger@mailjet.com"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    To send an email, you need the following mandatory properties:

    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.

    API response:

    {
        "Sent": [
            {
                "Email": "passenger@mailjet.com",
                "MessageID": 111111111111111,
                "MessageUUID": "1ab23cd4-e567-8901-2345-6789f0gh1i2j"
    
            }
        ]
    }
    

    After a successful POST request the response will include the recipient email, MessageID and MessageUUID.

    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.

    <?php
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $body = [
        '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>"
    ];
    $response = $mj->post(Resources::$Send, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # This calls 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>"
        }'
    
    /**
     *
     * This calls sends an email to two recipients in To and one recipient in CC.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send")
        .request({
            "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>"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # This calls sends an email to two recipients in To and one recipient in CC.
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']
      config.default_from = 'your default sending address'
    end
    variable = Mailjet::Send.create(from_email: "pilot@mailjet.com",from_name: "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>")
    
    """
    This calls sends an email to two recipients in To and one recipient in CC.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    data = {
      '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>'
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    /*
    This calls sends an email to two recipients in To and one recipient in CC.
    */
    package main
    import (
        "fmt"
        . "github.com/mailjet/mailjet-apiv3-go"
        "os"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        email := &InfoSendMail {
          FromEmail: "pilot@mailjet.com",
          FromName: "Mailjet Pilot",
          Subject: "Your email flight plan!",
          TextPart: "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
          HTMLPart: "<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>",
        },
        res, err := mailjetClient.SendMail(email)
        if err != nil {
                fmt.Println(err)
        } else {
                fmt.Println("Success")
                fmt.Println(res)
        }
    }
    
    package com.my.project;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Email;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This calls sends an email to two recipients in To and one recipient in CC.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Email.resource)
                            .property(Email.FROMEMAIL, "pilot@mailjet.com")
                            .property(Email.FROMNAME, "Mailjet Pilot")
                            .property(Email.SUBJECT, "Your email flight plan!")
                            .property(Email.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
                            .property(Email.HTMLPART, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                            .property(Email.TO, "Name <passenger@mailjet.com>, Name2 <passenger2@mailjet.com>")
                            .property(Email.CC, "Name3 <passenger@mailjet.com>");
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This calls sends an email to two recipients in To and one recipient in CC.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.FromEmail, "pilot@mailjet.com")
                .Property(Send.FromName, "Mailjet Pilot")
                .Property(Send.Subject, "Your email flight plan!")
                .Property(Send.TextPart, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
                .Property(Send.HtmlPart, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                .Property(Send.To, "Name <passenger@mailjet.com>, Name2 <passenger2@mailjet.com>")
                .Property(Send.Cc, "Name3 <passenger@mailjet.com>");
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    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.

    Send to multiple recipients

    """
    This calls sends an email to 2 recipients.
    """
    from mailjet_rest import Client
    import os
    api_key = os.environ['MJ_APIKEY_PUBLIC']
    api_secret = os.environ['MJ_APIKEY_PRIVATE']
    mailjet = Client(auth=(api_key, api_secret))
    data = {
      '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": "passenger1@mailjet.com",
                "Name": "passenger 1"
            },
            {
                "Email": "passenger2@mailjet.com",
                "Name": "passenger 2"
            }
        ]
    }
    result = mailjet.send.create(data=data)
    print result.status_code
    print result.json()
    
    package MyClass;
    import com.mailjet.client.errors.MailjetException;
    import com.mailjet.client.errors.MailjetSocketTimeoutException;
    import com.mailjet.client.MailjetClient;
    import com.mailjet.client.MailjetRequest;
    import com.mailjet.client.MailjetResponse;
    import com.mailjet.client.resource.Email;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * This calls sends an email to 2 recipients.
         */
        public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
          MailjetClient client;
          MailjetRequest request;
          MailjetResponse response;
          client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));
          request = new MailjetRequest(Email.resource)
                            .property(Email.FROMEMAIL, "pilot@mailjet.com")
                            .property(Email.FROMNAME, "Mailjet Pilot")
                            .property(Email.SUBJECT, "Your email flight plan!")
                            .property(Email.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
                            .property(Email.HTMLPART, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                            .property(Email.RECIPIENTS, new JSONArray()
                    .put(new JSONObject()
                        .put("Email", "passenger1@mailjet.com")
                        .put("Name", "passenger 1"))
                    .put(new JSONObject()
                        .put("Email", "passenger2@mailjet.com")
                        .put("Name", "passenger 2")));
          response = client.post(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    
    <?php
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $body = [
        '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' => "passenger1@mailjet.com",
                'Name' => "passenger 1"
            ],
            [
                'Email' => "passenger2@mailjet.com",
                'Name' => "passenger 2"
            ]
        ]
    ];
    $response = $mj->post(Resources::$Email, ['body' => $body]);
    $response->success() && var_dump($response->getData());
    ?>
    
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']
      config.default_from = 'your default sending address'
    end
    variable = Mailjet::Send.create(
            from_email: "pilot@mailjet.com",
            from_name: "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', 'Name' => 'passenger 1'}, {'Email' => 'passenger2@mailjet.com', 'Name' => 'passenger 2'}])
    
    # This calls sends an email to 2 recipients.
    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":"passenger1@mailjet.com","Name":"passenger 1"},{"Email":"passenger2@mailjet.com","Name":"passenger 2"}]
        }'
    
    /*
    This calls sends an email to 2 recipients.
    */
    package main
    import (
        "fmt"
        . "github.com/mailjet/mailjet-apiv3-go"
        "os"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        email := &InfoSendMail {
          FromEmail: "pilot@mailjet.com",
          FromName: "Mailjet Pilot",
          Subject: "Your email flight plan!",
          TextPart: "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
          HTMLPart: "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!",
          Recipients: []Recipient {
            Recipient {
              Email: "passenger1@mailjet.com",
              Name: "passenger 1",
            },
            Recipient {
              Email: "passenger2@mailjet.com",
              Name: "passenger 2",
            },
          },
        }
        res, err := mailjetClient.SendMail(email)
        if err != nil {
                fmt.Println(err)
        } else {
                fmt.Println("Success")
                fmt.Println(res)
        }
    }
    
    /**
     *
     * This calls sends an email to one recipient.
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .post("send")
        .request({
            "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":"passenger1@mailjet.com","Name":"passenger 1"},{"Email":"passenger2@mailjet.com","Name":"passenger 2"}]
        })
    request
        .then(result => {
            console.log(result.body)
        })
        .catch(err => {
            console.log(err.statusCode)
        })
    
    using Mailjet.Client;
    using Mailjet.Client.Resources;
    using System;
    using Newtonsoft.Json.Linq;
    namespace Mailjet.ConsoleApplication
    {
       class Program
       {
          /// <summary>
          /// This calls sends an email to 2 recipients.
          /// </summary>
          static void Main(string[] args)
          {
             RunAsync().Wait();
          }
          static async Task RunAsync()
          {
             MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"), Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));
             MailjetRequest request = new MailjetRequest
             {
                Resource = Send.Resource,
             }
                .Property(Send.FromEmail, "pilot@mailjet.com")
                .Property(Send.FromName, "Mailjet Pilot")
                .Property(Send.Subject, "Your email flight plan!")
                .Property(Send.TextPart, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
                .Property(Send.HtmlPart, "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!")
                .Property(Send.Recipients, new JArray {
                    new JObject {
                     {"Email", "passenger1@mailjet.com"},
                     {"Name", "passenger 1"}
                     },
                    new JObject {
                     {"Email", "passenger2@mailjet.com"},
                     {"Name", "passenger 2"}
                     }
                    });
             MailjetResponse response = await client.PostAsync(request);
             if (response.IsSuccessStatusCode)
             {
                Console.WriteLine(string.Format("Total: {0}, Count: {1}\n", response.GetTotal(), response.GetCount()));
                Console.WriteLine(response.GetData());
             }
             else
             {
                Console.WriteLine(string.Format("StatusCode: {0}\n", response.StatusCode));
                Console.WriteLine(string.Format("ErrorInfo: {0}\n", response.GetErrorInfo()));
                Console.WriteLine(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
             }
          }
       }
    }
    

    API response:

    {
        "Sent": [
            {
                "Email": "passenger1@mailjet.com",
                "MessageID"