NAV Navbar
cURL PHP NODE RUBY PYTHON GO JAVA C#
  • Getting Started
  • Filtering resources
  • 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
  • Managing Contacts in bulk
  • Domains and DNS
  • Account management
  • SMTP Relay
  • Exclusion List
  • The libraries
  • Demos
  • Google Cloud Platform
  • MJML
  • Need Help?
  • Getting Started

    This is a quick tutorial to get you started using our API.

    We will show you how to send your first email, how to authenticate with our API and tell you more about Mailjet RESTful API.

    We will also show you how to verify your domain to get a better deliverability of your emails.

    Make your first request

    Give it a go and send your first email...

    This simple example shows how to send an email with the API in a few easy steps.

    First, you need to have at least one active sender address in the Mailjet system. Visit the Sender domains & addresses section to check and setup your domain and sender.

    Second, you need to find your credentials, the API Key and the API Private Key, in the account/API Keys section.

    Example available only with CURL

    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": 
                                    }
                            ],
                            "Subject": "My first Mailjet Email!",
                            "TextPart": "Greetings from Mailjet."
                    }
            ]
        }'
    

    Now run the Curl command line, after replacing:

    About the Mailjet RESTful API

    API in a Nutshell

    The Mailjet API is designed to be RESTful compliant. This means that the API communicate over HTTP (including the use of HTTP verbs) . The API allows you to create, read, update and delete (CRUD) resources. Also, each single resource has a URI (Unique Resource Identifier) to help access its properties.

    The CRUD methods on the Mailjet API correspond to HTTP's verbs POST, GET, PUT and DELETE, so that depending on the resources and providing you have the access rights, you can do the following :

    Each resource has a list of properties and methods you can see in our API reference.

    Authenticate

    In order to use the Mailjet API you have to authenticate using HTTP Basic Auth. HTTP Basic Auth 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, which are both generated for you after registration.

    #To make better use of our cURL examples you can set your keys in your environment variables with the following commands: 
    export MJ_APIKEY_PUBLIC=xxxxxxxxxxxxxxxxxxxxxx
    export MJ_APIKEY_PRIVATE=xxxxxxxxxxxxxxxxxxxxxxx
    
    #View user information : now, you don't need to replace $MJ_APIKEY_PUBLIC and $MJ_APIKEY_PRIVATE when running a cURL command
    curl --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" https://api.mailjet.com/v3/REST/user
    

    The server should respond with the following data:

    {
        "Count": 1,
        "Data": [
            {
                "ACL": "",
                "CreatedAt": "",
                "Email": "miss@mailjet.com",
                "ID": "",
                "LastIp": "",
                "LastLoginAt": "",
                "Locale": "",
                "MaxAllowedAPIKeys": "5",
                "Timezone": "",
                "Username": "",
                "WarnedRatelimitAt": ""
            }
        ],
        "Total": 1
    }
    

    Most developers use one of our API libraries for their production systems and the respective library documentation tells you where to place your API Keys. However for testing purposes it can be nice to query the API directly from the shell.

    In this example :

    Both these keys can be found in your control panel, once you're logged-in and your account is provisioned (activated).

    The usual json payload response will have the following structure : {"Count": int, "Data": array, "Total": int} where Count and Total represent the number of lines affected by your API call. When using the countOnly filter Total will be the global number of elements corresponding to your API call.

    Status Codes

    These status codes will be sent back by the API to notify of the success or failure of your calls.

    Code Description
    200 OK All went well. Congrats!
    201 Created The POST request was successfully executed.
    204 No Content No content found or expected to return. Returned when DELETE was successful.
    304 Not Modified The PUT request didn't affect any record.
    400 Bad Request One or more parameters are missing or maybe mispelled (unknown resource or action)
    401 Unauthorized You have specified an incorrect Api Key / API Secret Key. You may be unauthorized to access the API or your API key may be expired. Visit API keys Management section to check your keys.
    403 Forbidden You are not authorised to access this resource.
    404 Not Found The resource with the specified ID you are trying to reach does not exist.
    405 Method Not Allowed The method requested on the resource does not exist.
    429 Too Many Requests Oops! You have reach the maximum number of calls allowed per minute by our API. Please review your integration to reduce the number of call issued by your system.
    500 Internal Server Error Ouch! Something went wrong on our side and we apologize! When such error occurs, it will contain an error identifier in it's description (e.g. "ErrorIdentifier" : "D4DF574C-0C5F-45C7-BA52-7AA8E533C3DE"), which is crucial for us to track the problem and identify the root cause. Please contact our support team , providing the error identifier and we will do our best to help.
    {
        "ErrorInfo": "Bad Request",
        "ErrorMessage": "Unknown resource: \"contacts\"",
        "StatusCode": 400
    }
    

    In addition to the status codes, in case of error, you can find hints in a standardised JSON response with the reason under ErrorMessage.

    In case of a 429 Too Many Requests error, keep in mind that Mailjet API offers multiple bulk functionalities to replace and ease some heavy duty API needs :

    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!

    Where to go from here?

    In the next sections of this guide, you will find 2 common user cases:

    You can also discover our real time notification API that allows you to monitor every event (sent, opened, clicked, bounced...) on the emails you will send.

    Mailjet also offers an inbound emails parsing solution that allows to easily manage your contacts replies.

    Filtering resources

    https://api.mailjet.com/v3/REST/endpoint?filter1=this&filter2=that&filter3=it
    

    The Mailjet API provides a set of general filters that can be applied to a GET request for each resource. In addition to these general filters, each API resource has its own filters that can be used when performing the GET. You can find these filters in their respective resource description.

    To use a filter in a GET, you can amend the resource URL with a standard query string (?filter1=this&filter2=that&filter3=it).

    Mailjet API supports filter combination following these rules:

    The Limit Filter

    <?php
    /*
    View : List of 150 contacts
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'Limit' => '150'
    ];
    $response = $mj->get(Resources::$Contact, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # View : List of 150 contacts
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact?Limit=150 
    
    /**
     *
     * View : List of 150 contacts
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .request({
            "Limit":150
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : List of 150 contacts
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Contact.all(limit: "150"
    )
    p variable.attributes['Data']
    
    """
    View : List of 150 contacts
    """
    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 = {
      'Limit': '150'
    }
    result = mailjet.contact.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    View : List of 150 contacts
    */
    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.Contact
        _, _, err := mailjetClient.List("contact", &data, Filter("Limit", "150"))
        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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : List of 150 contacts
         */
        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(Contact.resource)
                      .filter(Contact.LIMIT, "150");
          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 : List of 150 contacts
          /// </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 = Contact.Resource,
             }
             .Filter(Contact.Limit, "150");
             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 limit the number of results by applying the Limit filter. The default value is 10 and the maximum value is 1000. Limit=0 delivers the maximum amount of results - 1000.

    The Offset Filter

    <?php
    /*
    View : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'Offset' => '25000'
    ];
    $response = $mj->get(Resources::$Contact, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # View : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact?Offset=25000 
    
    /**
     *
     * View : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .request({
            "Offset":25000
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Contact.all(offset: "25000"
    )
    p variable.attributes['Data']
    
    """
    View : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
    """
    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 = {
      'Offset': '25000'
    }
    result = mailjet.contact.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    View : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
    */
    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.Contact
        _, _, err := mailjetClient.List("contact", &data, Filter("Offset", "25000"))
        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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
         */
        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(Contact.resource)
                      .filter(Contact.OFFSET, "25000");
          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 : List of contact with Offset, delivers 10 contacts, starting with the 25000th contact
          /// </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 = Contact.Resource,
             }
             .Filter(Contact.Offset, "25000");
             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 use the Offset filter to retrieve a list starting from a certain offset.

    <?php
    /*
    View : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'Limit' => '150',
      'Offset' => '25000'
    ];
    $response = $mj->get(Resources::$Contact, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # View : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact?Limit=150\&Offset=25000 
    
    /**
     *
     * View : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .request({
            "Limit":150,
            "Offset":25000
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    /*
    View : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
    */
    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.Contact
        _, _, err := mailjetClient.List("contact", &data, Filter("Limit", "150"), Filter("Offset", "25000"))
        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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
         */
        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(Contact.resource)
                      .filter(Contact.LIMIT, "150")
                      .filter(Contact.OFFSET, "25000");
          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 : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
          /// </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 = Contact.Resource,
             }
             .Filter(Contact.Limit, "150")
             .Filter(Contact.Offset, "25000");
             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()));
             }
          }
       }
    }
    
    # View : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Contact.all(limit: "150",
    offset: "25000"
    )
    p variable.attributes['Data']
    
    """
    View : List of contacts with Limit and Offset, retrieves a list of 150 contacts starting with the 25000th contact
    """
    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 = {
      'Limit': '150',
      'Offset': '25000'
    }
    result = mailjet.contact.get(filters=filters)
    print result.status_code
    print result.json()
    

    The Offset filter can be combined with the Limit filter.

    The Sort Filter

    <?php
    /*
    View : List of contact ordered by email in an ascending order
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'Sort' => 'email'
    ];
    $response = $mj->get(Resources::$Contact, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # View : List of contact ordered by email in an ascending order
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact?Sort=email 
    
    /**
     *
     * View : List of contact ordered by email in an ascending order
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .request({
            "Sort":"email"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : List of contact ordered by email in an ascending order
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Contact.all(sort: "email"
    )
    p variable.attributes['Data']
    
    """
    View : List of contact ordered by email in an ascending order
    """
    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 = {
      'Sort': 'email'
    }
    result = mailjet.contact.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    View : List of contact ordered by email in an ascending order
    */
    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.Contact
        _, _, err := mailjetClient.List("contact", &data, Filter("Sort", "email"))
        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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : List of contact ordered by email in an ascending order
         */
        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(Contact.resource)
                      .filter(Contact.SORT, "email");
          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 : List of contact ordered by email in an ascending order
          /// </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 = Contact.Resource,
             }
             .Filter(Contact.Sort, "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()));
             }
          }
       }
    }
    

    You can sort a GET query by specifying a property name as the value of the 'Sort' filter. The default sorting is ascending. When a property name is postfixed with DESC (ie property_name DESC, seperated by a space) , the sort order is descending.

    Please note that the Sort filter does not work with all properties and that the DESC is not available for all properties.

    <?php
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'Sort' => 'email DESC'
    ];
    $response = $mj->get(Resources::$Contact, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # View : List of contact ordered by email in reverse order
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact?Sort=email+DESC 
    
    /**
     *
     * View : List of contact ordered by email in reverse order
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .request({
            "Sort":"email DESC"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : List of contact ordered by email in reverse order
    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::Contact.all(sort: "email DESC")
    
    """
    View : List of contact ordered by email in reverse order
    """
    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 = {
      'Sort': 'email DESC'
    }
    result = mailjet.contact.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    View : List of contact ordered by email in reverse order
    */
    package main
    import (
        "fmt"
        . "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
        "os"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Contact
        _, _, err := mailjetClient.List("contact", &data, Filter("Sort", "email DESC"))
        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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : List of contact ordered by email in reverse order
         */
        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(Contact.resource)
                      .filter(Contact.SORT, "email DESC");
          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 : List of contact ordered by email in an ascending order
            /// </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 = Contact.Resource,
                }
                      .Filter(Contact.Sort, "email DESC");
                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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
                }
            }
        }
    }
    

    To retrieve the same query only in descending order, amend the sort filter with DESC:

    Resource Filters

    <?php
    /*
    View : Contacts in ContactsList
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'ContactsList' => '$ContactsListID'
    ];
    $response = $mj->get(Resources::$Contact, ['filters' => $filters]);
    $response->success() && var_dump($response->getData());
    ?>
    
    # View : Contacts in ContactsList
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact?ContactsList=$ContactsListID 
    
    /**
     *
     * View : Contacts in ContactsList
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .request({
            "ContactsList":"$ContactsListID"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : Contacts in ContactsList
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Contact.all(contacts_list: "$ContactsListID"
    )
    p variable.attributes['Data']
    
    """
    View : Contacts in ContactsList
    """
    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 = {
      'ContactsList': '$ContactsListID'
    }
    result = mailjet.contact.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    View : Contacts in ContactsList
    */
    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.Contact
        _, _, err := mailjetClient.List("contact", &data, Filter("ContactsList", "$ContactsListID"))
        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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : Contacts in ContactsList
         */
        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(Contact.resource)
                      .filter(Contact.CONTACTSLIST, "$ContactsListID");
          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 : Contacts in ContactsList
          /// </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 = Contact.Resource,
             }
             .Filter(Contact.Contactslist, "$ContactsListID");
             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()));
             }
          }
       }
    }
    

    On each resource, the API provide specific filters. Visit the reference to see what is available.

    Unique Key Filters

    # View : Contact from email address
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact/$EMAIL_ADDRESS_OR_CONTACT_ID 
    
    <?php
    /*
    View : Contact from email address
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $response = $mj->get(Resources::$Contact, ['id' => $id]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * View : Contact from email address
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .id($EMAIL_ADDRESS_OR_CONTACT_ID)
        .request()
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : Contact from email address
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Contact.find($EMAIL_ADDRESS_OR_CONTACT_ID)
    p variable.attributes['Data']
    
    """
    View : Contact from email address
    """
    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 = '$EMAIL_ADDRESS_OR_CONTACT_ID'
    result = mailjet.contact.get(id=id)
    print result.status_code
    print result.json()
    
    /*
    View : Contact from email address
    */
    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.Contact
        mr := &Request{
          Resource: "contact",
          ID: RESOURCE_ID,
        }
        err := mailjetClient.Get(mr, &data)
        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>
          /// View : Contact from email address
          /// </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 = Contact.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()));
             }
          }
       }
    }
    
    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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : Contact from email address
         */
        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(Contact.resource, ID);
          response = client.get(request);
          System.out.println(response.getStatus());
          System.out.println(response.getData());
        }
    }
    

    You can access each unique element using unique key filter. Visit the reference to see the keys available for each resource.

    # View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/eventcallbackurl/$EventType|$isBackup 
    
    <?php
    /*
    View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
    */
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $response = $mj->get(Resources::$Eventcallbackurl, ['id' => $id]);
    $response->success() && var_dump($response->getData());
    ?>
    
    /**
     *
     * View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("eventcallbackurl")
        .id($EventType|$isBackup)
        .request()
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
    require 'mailjet'
    Mailjet.configure do |config|
      config.api_key = ENV['MJ_APIKEY_PUBLIC']
      config.secret_key = ENV['MJ_APIKEY_PRIVATE']  
    end
    variable = Mailjet::Eventcallbackurl.find($EventType|$isBackup)
    p variable.attributes['Data']
    
    /*
    View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
    */
    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.Eventcallbackurl
        mr := &Request{
          Resource: "eventcallbackurl",
          ID: RESOURCE_ID,
        }
        err := mailjetClient.Get(mr, &data)
        if err != nil {
          fmt.Println(err)
        }
        fmt.Printf("Data array: %+v\n", data)
    }
    
    """
    View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
    """
    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 = '$EventType|$isBackup'
    result = mailjet.eventcallbackurl.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.Eventcallbackurl;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
         */
        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(Eventcallbackurl.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>
          /// View : event-driven callback URLs, also called webhooks, used by the Mailjet platform when a specific action is triggered
          /// </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 = Eventcallbackurl.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()));
             }
          }
       }
    }
    

    Whenever the unique key consists of several pieces of information, you can call this unique key combination by using the separator |.

    The Count Filter

    <?php
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
    $filters = [
      'countOnly' => '1'
    ];
    $response = $mj->get(Resources::$Contact, ['filters' => $filters]);
    $response->success() && var_dump($response->getTotal());
    ?>
    
    /**
     *
     * View : Total number of contact
     *
     */
    const mailjet = require ('node-mailjet')
        .connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)
    const request = mailjet
        .get("contact")
        .request({
            "countOnly":"1"
        })
    request
        .then((result) => {
            console.log(result.body)
        })
        .catch((err) => {
            console.log(err.statusCode)
        })
    
    # View : Total number of contact
    curl -s \
        -X GET \
        --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
        https://api.mailjet.com/v3/REST/contact?countOnly=1 
    
    # View : Total number of contact
    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::Contact.all(count_only: "1")
    
    """
    View : Total number of contact
    """
    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 = {
      'countOnly': '1'
    }
    result = mailjet.contact.get(filters=filters)
    print result.status_code
    print result.json()
    
    /*
    View : Total number of contact
    */
    package main
    import (
        "fmt"
        . "github.com/mailjet/mailjet-apiv3-go"
        "github.com/mailjet/mailjet-apiv3-go/resources"
        "os"
    )
    func main () {
        mailjetClient := NewMailjetClient(os.Getenv("MJ_APIKEY_PUBLIC"), os.Getenv("MJ_APIKEY_PRIVATE"))
        var data []resources.Contact
        _, _, err := mailjetClient.List("contact", &data, Filter("countOnly", "1"))
        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.Contact;
    import org.json.JSONArray;
    import org.json.JSONObject;
    public class MyClass {
        /**
         * View : Total number of contact
         */
        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(Contact.resource)
                      .filter(Contact.COUNTONLY, "1");
          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 : Total number of contact
            /// </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 = Contact.Resource,
                }
                .Filter(Contact.CountOnly, "1");
                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(string.Format("ErrorMessage: {0}\n", response.GetErrorMessage()));
                }
            }
        }
    }
    

    API response:

    {
        "Count": 152,
        "Data": [ ],
        "Total": 152
    }
    

    Use the filter countOnly to retrieve the number of records a resource will return. This filter will not extract any list of results but only count them.

    To navigate on a full set of results, we advise you to either use the filter countOnly to know how many pages of results you will need to extract or to simply loop with a change of Offset until you reach an empty set of results.

    Send transactional email

    Choose sending method

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

    SMTP Relay

    SMTP Relay to send email in a fairly easy way, requiring minimum integration effort on your side.

    The SMTP Relay is useful if you have an existing solution for transactional email 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 handle properly the error and retry to send 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 error. The use of Send API can be a better choice as it require 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 for you the delivery and queuing of your messages.

    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 programmatically way to send messages.

    Send API allows to send single messages but also to mutualise the calls by leveraging templating and personalisation 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.

    Prerequisites

    Verify a Sender

    # 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"
        }'
    
    <?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.
     *
     */
    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, dont forget to setup properly your DNS record.

    You can either visit the Mailjet user interface or use the Domains and DNS API guide to setup 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.

    Sending 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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 starts 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. You will be able to use this id to get more information about your message. Find details in our Message Statistics Guide

    MessageID is the unique ID of the message (legacy format)

    MessageHref is an 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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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"
            }
          ]
        }
      ]
    }
    

    Sending 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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 behaviour. 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\"> Mailjet!</h3><br />May the delivery force be with you!",
                'InlinedAttachments' => [
                    [
                        'ContentType' => "image/gif",
                        'Filename' => "logo.gif",
                        'ContentID' => "id1",
                        'Base64Content' => "R0lGODlhEAAQAOYAAP////748v39/Pvq1vr6+lJSVeqlK/zqyv7+/unKjJ+emv78+fb29pucnfrlwvTCi9ra2vTCa6urrWdoaurr6/Pz8uHh4vn49PO7QqGfmumaN+2uS1ZWWfr27uyuLnBxd/z8+0pLTvHAWvjar/zr2Z6cl+jal+2kKmhqcEJETvHQbPb07lBRVPv6+cjJycXFxn1+f//+/f337nF0efO/Mf306NfW0fjHSJOTk/TKlfTp0Prlx/XNj83HuPfEL+/v8PbJgueXJOzp4MG8qUNES9fQqN3d3vTJa/vq1f317P769f/8+gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4wLWMwNjAgNjEuMTM0Nzc3LCAyMDEwLzAyLzEyLTE3OjMyOjAwICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MjY5ODYxMzYzMkJCMTFFMDkzQkFFMkFENzVGN0JGRkYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MjY5ODYxMzczMkJCMTFFMDkzQkFFMkFENzVGN0JGRkYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDoyNjk4NjEzNDMyQkIxMUUwOTNCQUUyQUQ3NUY3QkZGRiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDoyNjk4NjEzNTMyQkIxMUUwOTNCQUUyQUQ3NUY3QkZGRiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PgH//v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dzb2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vLu6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZmJeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAEAAAAALAAAAAAQABAAAAdUgACCg4SFhoeIiYRGLhaKhA0TMDgSLxAUiEIZHAUsIUQpKAo9Og6FNh8zJUNFJioYQIgJRzc+NBEkiAcnBh4iO4o8QRsjj0gaOY+CDwPKzs/Q0YSBADs="
                    ]
                ]
            ]
        ]
    ];
    $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\"> Mailjet!</h3><br />May the delivery force be with you!",
                            "InlinedAttachments": [
                                    {
                                            "ContentType": "image/gif",
                                            "Filename": "logo.gif",
                                            "ContentID": "id1",
                                            "Base64Content": "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"
                                    }
                            ]
                    }
            ]
        }'
    
    /**
     *
     * 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\"> Mailjet!</h3><br />May the delivery force be with you!",
                            "InlinedAttachments": [
                                    {
                                            "ContentType": "image/gif",
                                            "Filename": "logo.gif",
                                            "ContentID": "id1",
                                            "Base64Content": "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"
                                    }
                            ]
                    }
            ]
        })
    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\'> Mailjet!</h3><br />May the delivery force be with you!',
        'InlinedAttachments'=> [
            {
                'ContentType'=> 'image/gif',
                'Filename'=> 'logo.gif',
                'ContentID'=> 'id1',
                'Base64Content'=> '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'
            }
        ]
    }]
    )
    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\"> Mailjet!</h3><br />May the delivery force be with you!",
                            "InlinedAttachments": [
                                    {
                                            "ContentType": "image/gif",
                                            "Filename": "logo.gif",
                                            "ContentID": "id1",
                                            "Base64Content": "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"
                                    }
                            ]
                    }
            ]
    }
    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\"> Mailjet!</h3><br />May the delivery force be with you!",
            InlinedAttachments: &mailjet.InlinedAttachmentsV31{
              mailjet.InlineAttachmentV31 {
                ContentType: "image/gif",
                Filename: "logo.gif",
                ContentID: "id1",
                Base64Content: "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",
              },
            },
          },
        }
        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\"> Mailjet!</h3><br />May the delivery force be with you!")
                        .put(Emailv31.Message.INLINEDATTACHMENTS, new JSONArray()
                            .put(new JSONObject()
                                .put("ContentType", "image/gif")
                                .put("Filename", "logo.gif")
                                .put("ContentID", "id1")
                                .put("Base64Content", "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")))));
          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\"> Mailjet!</h3><br />May the delivery force be with you!"},
                     {"InlinedAttachments", new JArray {
                      new JObject {
                       {"ContentType", "image/gif"},
                       {"Filename", "logo.gif"},
                       {"ContentID", "id1"},
                       {"Base64Content", "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"}
                       }
                      }}
                     }
                    });
             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 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"/>

    Sending 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 Mailjet!</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 Mailjet!</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 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 Mailjet!</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 Mailjet!</h3><br />May the delivery force be with you!"
                    }
            ]
        }'
    
    # 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 Mailjet!</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 Mailjet!</h3><br />May the delivery force be with you!'
    }]
    )
    p variable.attributes['Messages']
    
    /**
     *
     * 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 Mailjet!</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 Mailjet!</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 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 Mailjet!</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 Mailjet!</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 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 Mailjet!</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 Mailjet!</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 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 Mailjet!</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 Mailjet!</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 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 Mailjet!</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 Mailjet!</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": 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 error 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.

    Personalisation

    Content formatting

    Mailjet offers a templating language that allows you to personalise 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 Transactional templating guide to learn about additional substitutions, modification functions and conditional statements you can use to personalise messages.

    Using 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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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.
    """
    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 Mailjet!</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()
    
    /*
    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 Mailjet!</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)
    }
    
    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 Mailjet!</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 Mailjet!</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.

    Using 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 Mailjet!</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 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 Mailjet!</h3><br /> May the delivery force be with you!"
                    }
            ]
        }'
    
    /**
     *
     * 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 Mailjet!</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 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 Mailjet!</h3><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 Mailjet!</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 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 Mailjet!</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 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 Mailjet!</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 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 Mailjet!</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()));
             }
          }
       }
    }
    

    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 personalise your email.

    Use {{data:METADATA_NAME}} or {{data:METADATA_NAME:DEFAULT_VALUE}} to insert data in your content.

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

    More information about how to add contact properties.

    Using 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 personalisation ([[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.

    Using Templating Language

    # 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 Mailjet!</h3><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!"
                            }
                    }
            ]
        }'
    
    <?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 Mailjet!</h3><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.
     *
     */
    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 Mailjet!</h3><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 Mailjet!</h3><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.
    */
    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 Mailjet!</h3><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)
    }
    
    """
    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 Mailjet!</h3><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()
    
    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 Mailjet!</h3><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 Mailjet!</h3><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 to leverage Mailjet templating language in your transactional messages.

    The Mailjet Templating Language enables you to achieve:

    Find our dedicated guide here.

    Adding 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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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

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

    Sending 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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 trace back the message in our system easily. 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()
    
    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());
        }
    }
    
    /*
    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)
    }
    
    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.

    Sending 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 Mailjet!</h3><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 Mailjet!</h3><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.
     *
     */
    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 Mailjet!</h3><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.
    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 Mailjet!</h3><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.
    """
    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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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.

    Grouping 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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 Mailjet!</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 pulling advanced statistics of your transaction 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.

    Adding 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 trackings 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 of 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 the url of 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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 the validation 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 errors 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 omiting 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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 alert

    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 collection of messages, represented as 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 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 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 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 Activate 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 overriding account preferences.
    Can only be used with a HTML part.
    Accept 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 overriding account preferences.
    Can only be specified if the HTML part is provided.
    Accept 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 personalisation 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 occur 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 separately each message. As a result, the response can contain 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-0001 when an unexpected property is provided.
    400 send-0002 when a property is set more than once in the input payload.
    400 send-0003 when none of HTML, Text, TemplateID properties are provided. HTMLPart, TextPart, TemplateID
    400 send-0004 when providing HTML property and providing template also containing an HTML part - ie Duplicated content HTMLPart, TemplateID
    403 send-0005 when providing Text property and providing template also containinig a text part - ie Duplicated content TextPart, TemplateID
    403 send-0006 when the API key doesn’t have permission to use Sender header. Please contact our support team to be granted permission. SenderID
    403 send-0007 when SenderID is provided but not validated. SenderID
    400 send-0008 when sender email address provided in the From property is not authorized. The validation can be done on the Sender domains & addresses page or through 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-0014 when MonitoringCategory was deleted. 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
    400 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 array property contains more than the maximum allowed number of elements. Messages
    Attachments
    InlineAttachments
    Headers
    Variables
    400 mj-0011 when payload size is over the limit.
    400 mj-0012 when an empty string value is provided. Email
    Base64Content
    ContentType
    400 mj-0013 when 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

    Sending 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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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 Mailjet!</h3><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
            }
        ]
    }
    
    <?php
    require 'vendor/autoload.php';
    use \Mailjet\Resources;
    $mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv(<