{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml","oas-openapi/openapi-mailjet.yaml":"oas-openapi/openapi-mailjet.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition","openapi-code-sample","tabs","tab"]},"type":"markdown"},"seo":{"title":"Send a basic email","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Send a basic transactional email with Mailjet Send API v3.1: build a Messages array with From, To, Subject, and HTMLPart, then POST to the v3.1 endpoint.","image":"https://dev.mailjet.com/og-image.png","lang":"en-US","keywords":["Mailjet API","Email API","Content API","SMTP Relay","transactional email","email delivery","Send API","email templates","developer documentation"],"meta":[{"name":"og:type","content":"website"},{"name":"og:site_name","content":"Mailjet Developer Documentation"},{"name":"twitter:card","content":"summary_large_image"},{"name":"robots","content":"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"},{"name":"googlebot","content":"index, follow, max-snippet:-1, max-image-preview:large"}],"jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://dev.mailjet.com/#organization","name":"Mailjet","alternateName":"Sinch Mailjet","url":"https://www.mailjet.com","logo":"https://assets.mailjet.com/lib/images/mailjetLogo/mj_logo_with_text_color.png","parentOrganization":{"@type":"Organization","name":"Sinch","url":"https://www.sinch.com"}},{"@type":"WebSite","@id":"https://dev.mailjet.com/#website","name":"Mailjet Developer Documentation","description":"Official developer documentation for the Mailjet Email API, Content API and SMTP Relay.","url":"https://dev.mailjet.com/","inLanguage":"en-US","publisher":{"@id":"https://dev.mailjet.com/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://dev.mailjet.com/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]},"llmstxt":{"hide":false,"title":"Mailjet Developer Documentation","description":"Developer documentation for the Mailjet Email API, Content API and SMTP Relay - guides, API references and code samples for sending, templating and tracking email at scale.","details":{"content":"Mailjet (part of Sinch) provides APIs for sending and managing email.\n\nThis documentation covers four main areas:\n\n- **Email API** - the Send API (v3 and v3.1) for transactional and marketing email,\n  plus contact management, segmentation, campaigns, statistics, webhooks, the Parse API\n  and the Mailjet Templating Language.\n- **Content API** - programmatic management of email templates, template contents,\n  images, labels and authentication tokens (v1).\n- **SMTP Relay** - sending through Mailjet's SMTP servers, including custom headers.\n- **API Reference** - the complete, generated reference for every endpoint, built directly\n  from the OpenAPI specifications.\n\nBase URL for all REST APIs: `https://api.mailjet.com`.\nAuthentication uses HTTP Basic auth with an API key and secret key.\n\n## Machine-readable entry points\n\nPrefer these when you need the API surface in as few requests as possible:\n\n- `/openapi/openapi-mailjet.md` - the **complete** Email API reference (every endpoint,\n  grouped by resource) as a single Markdown document.\n- `/openapi/openapi-passport.md` - the **complete** Content API reference as a single\n  Markdown document.\n- `/_bundle/openapi/openapi-mailjet.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Email API.\n- `/_bundle/openapi/openapi-passport.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Content API.\n- `/sitemap.xml` - every indexable URL on this site.\n\nEvery page on this site is also available as clean Markdown by appending `.md` to its URL."},"sections":[{"title":"Email API","description":"Sending, contacts, campaigns, statistics, webhooks and templating.","includeFiles":["docs/email-api/**/*.md"],"excludeFiles":[]},{"title":"Content API","description":"Manage templates, template contents, images, labels and tokens.","includeFiles":["docs/content-api/**/*.md","docs/content-api.md"],"excludeFiles":[]},{"title":"SMTP Relay","description":"Send email through Mailjet's SMTP servers.","includeFiles":["docs/smtp-relay/**/*.md"],"excludeFiles":[]},{"title":"API Reference","description":"Complete generated reference for every Mailjet API endpoint.","includeFiles":["openapi/openapi-mailjet.yaml","openapi/openapi-passport.yaml","docs/api-reference/**/*.md"],"excludeFiles":[]},{"title":"Migrating from Mandrill","description":"Guides for switching from Mandrill to Mailjet.","includeFiles":["docs/mandrill/**/*.md"],"excludeFiles":[]}],"excludeFiles":[]},"priority":0.8},"dynamicMarkdocComponents":["openapi"],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"send-a-basic-email","__idx":0},"children":["Send a basic email"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Send API v3.1 expects a JSON payload with a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Messages"]}," array."," ","Each object in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Messages"]}," represents one message to process."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"required-message-properties","__idx":1},"children":["Required message properties"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For each message, these properties are required:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["From"]},": JSON object with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Email"]}," and optionally ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Name"]},"."," ","The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Email"]}," must be a previously ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://app.mailjet.com/account/sender"},"children":["validated and active sender"]},"."," ","Format: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{ \"Email\": \"value\", \"Name\": \"value\" }"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["To"]},": array of recipient objects."," ","Each recipient requires ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Email"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Name"]}," is optional."," ","Format: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[{ \"Email\": \"value\", \"Name\": \"value\" }, ...]"]},"."," ","The same object structure applies to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Cc"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Bcc"]},"."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You must also provide one of the following content options:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TextPart"]}," and/or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["HTMLPart"]},": message body in plain text and/or HTML."," ","At least one must be present when not using templates."," ","If only ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["HTMLPart"]}," is provided, Mailjet does not generate a text part automatically."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TemplateID"]},": ID of a Mailjet template."," ","Use this when content comes from a stored template."," ","When template content is used, do not set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TextPart"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["HTMLPart"]},"."]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Important: The recipients listed in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["To"]}," will receive a common message, showing every other recipient and carbon copy (CC) recipients. If you do not wish the recipients to see each other, you have to create multiple messages in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Messages"]}," array."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-one-recipient","__idx":2},"children":["Example: one recipient"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This call sends a message to one recipient."]},{"$$mdtype":"Tag","name":"OpenApiCodeSample","attributes":{"descriptionFile":"oas-openapi/openapi-mailjet.yaml","operationId":"postSendV31","parameters":{},"environments":{},"codeSamplesResolved":[{"lang":"shell","title":"cURL","source":"curl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3.1/send \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n      \"SandboxMode\":true,\n      \"Messages\":[\n        {\n          \"From\":{\n            \"Email\":\"pilot@mailjet.com\",\n            \"Name\":\"Your Mailjet Pilot\"\n          },\n          \"HTMLPart\":\"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n          \"Subject\":\"Your email flight plan!\",\n          \"TextPart\":\"Dear passenger, welcome to Mailjet! May the delivery force be with you!\",\n          \"To\":[\n            {\n              \"Email\":\"passenger@mailjet.com\",\n              \"Name\":\"Passenger 1\"\n            }\n          ]\n        }\n      ]\n\t}'"},{"lang":"php","title":"PHP","source":"<?php\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);\n$body = [\n  'SandboxMode' => true,\n  'Messages' => [\n    [\n      'From' => [\n        'Email' => \"pilot@mailjet.com\",\n        'Name' => \"Your Mailjet Pilot\"\n      ],\n      'HTMLPart' => \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n      'Subject' => \"Your email flight plan!\",\n      'TextPart' => \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\",\n      'To' => [\n        [\n          'Email' => \"passenger@mailjet.com\",\n          'Name' => \"Passenger 1\"\n        ]\n      ]\n    ]\n  ]\n];\n$response = $mj->post(Resources::$Email, ['body' => $body]);\n$response->success() && var_dump($response->getData());\n?>"},{"lang":"javascript","title":"Node","source":"const mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"send\", {'version': 'v3.1'})\n\t.request({\n      \"SandboxMode\":true,\n      \"Messages\":[\n        {\n          \"From\":{\n            \"Email\":\"pilot@mailjet.com\",\n            \"Name\":\"Your Mailjet Pilot\"\n          },\n          \"HTMLPart\":\"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n          \"Subject\":\"Your email flight plan!\",\n          \"TextPart\":\"Dear passenger, welcome to Mailjet! May the delivery force be with you!\",\n          \"To\":[\n            {\n             \"Email\":\"passenger@mailjet.com\",\n             \"Name\":\"Passenger 1\"\n            }\n          ]\n        }\n      ]\n    })\nrequest\n\t.then((result) => {\n\t\tconsole.log(result.body)\n\t})\n\t.catch((err) => {\n\t\tconsole.log(err.statusCode)\n\t})"},{"lang":"ruby","title":"Ruby","source":"require 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']\n  config.api_version = \"v3.1\"\nend\nvariable = Mailjet::Send.create(\n  sandbox_mode: true,\n  messages: [\n    {\n      'from': {\n        'email' => \"pilot@mailjet.com\",\n        'name' => \"Your Mailjet Pilot\"\n      },\n      'htmlpart' => \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n      'subject' => \"Your email flight plan!\",\n      'text_part' => \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\",\n      'to': [\n        {\n          'email' => \"passenger@mailjet.com\",\n          'name' => \"Passenger 1\"\n        }\n      ]\n    }\n  ]\n)\np variable.attributes['Messages']"},{"lang":"python","title":"Python","source":"from mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret), version='v3.1')\ndata = {\n  'SandboxMode': True,\n  'Messages': [\n    {\n      'From': {\n        \"Email\": \"pilot@mailjet.com\",\n        \"Name\": \"Your Mailjet Pilot\"\n      },\n      \"HTMLPart\": \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\",\n      \"Subject\": \"Your email flight plan!\",\n      \"TextPart\": \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\",\n      'To': [\n        {\n          \"Email\": \"passenger@mailjet.com\",\n          \"Name\": \"Passenger 1\"\n        }\n      ]\n    }\n  ]\n}\nresult = mailjet.send.create(data=data)\nprint result.status_code\nprint result.json()"},{"lang":"java","title":"Java","source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.ClientOptions;\nimport com.mailjet.client.resource.Emailv31;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"), new ClientOptions(\"v3.1\"));\n      request = new MailjetRequest(Emailv31.resource)\n            .property(Emailv31.SANDBOXMODE, true)\n            .property(Emailv31.MESSAGES, new JSONArray()\n                .put(new JSONObject()\n                    .put(Emailv31.Message.FROM, new JSONObject()\n                        .put(\"Email\", \"pilot@mailjet.com\")\n                        .put(\"Name\", \"Your Mailjet Pilot\")\n                    )\n                    .put(\"HTMLPart\", \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\")\n                    .put(\"Subject\", \"Your email flight plan!\")\n                    .put(\"TextPart\", \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\")\n                    .put(Emailv31.Message.TO, new JSONArray()\n                        .put(new JSONObject()\n                            .put(\"Email\", \"passenger@mailjet.com\")\n                            .put(\"Name\", \"Passenger 1\")\n                        )\n                    )\n                    )\n            )\n      );\n      response = client.post(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}"},{"lang":"go","title":"Go","source":"package main\n\nimport (\n  \"fmt\"\n  \"bytes\"\n  \"net/http\"\n  \"io/ioutil\"\n)\n\nfunc main() {\n  reqUrl := \"https://api.mailjet.com/v3.1/send\"\n  var data = []byte(`{\n    \"Messages\": [\n      {\n        \"From\": {\n          \"Email\": \"no-reply@example.com\",\n          \"Name\": \"Example Sender\"\n        },\n        \"To\": [\n          {\n            \"Email\": \"contact@example.com\",\n            \"Name\": \"Example Contact\"\n          }\n        ],\n        \"Subject\": \"Hello from Mailjet\",\n        \"TextPart\": \"Greetings from Mailjet!\",\n        \"HTMLPart\": \"<h3>Hello from Mailjet</h3>\"\n      }\n    ]\n  }`)\n  req, err := http.NewRequest(\"POST\", reqUrl, bytes.NewBuffer(data))\n  if err != nil {\n    panic(err)\n  }\n  req.SetBasicAuth(\"<username>\", \"<password>\")\n  req.Header.Add(\"Content-Type\", \"application/json\")\n  res, err := http.DefaultClient.Do(req)\n  if err != nil {\n    panic(err)\n  }\n  defer res.Body.Close()\n  body, err := ioutil.ReadAll(res.Body)\n  if err != nil {\n    panic(err)\n  }\n\n  fmt.Println(res)\n  fmt.Println(string(body))\n}"},{"lang":"csharp","title":"C#","source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"))\n         {\n            Version = ApiVersion.V3_1,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Send.Resource,\n         }\n             .Property(Send.SandboxMode, true)\n             .Property(Send.Messages, new JArray {\n                 new JObject {\n                     {\"From\", new JObject {\n                         {\"Email\", \"pilot@mailjet.com\"},\n                         {\"Name\", \"Your Mailjet Pilot\"}\n                     }},\n                     {\"HTMLPart\", \"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!\"},\n                     {\"Subject\", \"Your email flight plan!\"},\n                     {\"TextPart\", \"Dear passenger, welcome to Mailjet! May the delivery force be with you!\"},\n                     {\"To\", new JArray {\n                         new JObject {\n                             {\"Email\", \"passenger@mailjet.com\"},\n                             {\"Name\", \"Passenger 1\"}\n                         }\n                     }}\n                 }\n             });\n         MailjetResponse response = await client.PostAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}"}]},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response","__idx":3},"children":["API response"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"Messages\": [\n    {\n      \"Status\": \"success\",\n      \"To\": [\n        {\n          \"Email\": \"passenger1@mailjet.com\",\n          \"MessageUUID\": \"123\",\n          \"MessageID\": 456,\n          \"MessageHref\": \"https://api.mailjet.com/v3/message/456\"\n        }\n      ]\n    }\n  ]\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The response contains a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Messages"]}," array."," ","Each message result includes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Status"]}," and per-recipient tracking metadata for ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["To"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Cc"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Bcc"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MessageUUID"]}," is the internal Mailjet ID of your message."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MessageID"]}," is the unique ID of the message (legacy format), which you can use to fetch more message details."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MessageHref"]}," is the API URL where message metadata can be retrieved. It includes the API base URL, message resource path, and message ID (not UUID)."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Notice: If you send an email to a contact that does not exist yet in Mailjet, the contact is automatically created and saved."," ","If you plan to use that address later (for example in a contact list), there is no need to create it again."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-multiple-recipients-with-cc-and-bcc","__idx":4},"children":["Example: multiple recipients with Cc and Bcc"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"# This call sends a message to one recipient.\ncurl -s \\\n\t-X POST \\\n\t--user \"$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE\" \\\n\thttps://api.mailjet.com/v3.1/send \\\n\t-H 'Content-Type: application/json' \\\n\t-d '{\n\t\t\"Messages\":[\n\t\t\t\t{\n\t\t\t\t\t\t\"From\": {\n\t\t\t\t\t\t\t\t\"Email\": \"pilot@mailjet.com\",\n\t\t\t\t\t\t\t\t\"Name\": \"Mailjet Pilot\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"To\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"passenger1@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"passenger 1\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"passenger2@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"passenger 2\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Cc\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"copilot@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"Copilot\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Bcc\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"air-traffic-control@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"Air traffic control\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Subject\": \"Your email flight plan!\",\n\t\t\t\t\t\t\"TextPart\": \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\",\n\t\t\t\t\t\t\"HTMLPart\": \"<h3>Dear passenger 1, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\"\n\t\t\t\t}\n\t\t]\n\t}'\n","lang":"shell"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"PHP","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"<?php\n/*\nThis call sends a message to one recipient.\n*/\nrequire 'vendor/autoload.php';\nuse \\Mailjet\\Resources;\n$mj = new \\Mailjet\\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'),true,['version' => 'v3.1']);\n$body = [\n    'Messages' => [\n        [\n            'From' => [\n                'Email' => \"pilot@mailjet.com\",\n                'Name' => \"Mailjet Pilot\"\n            ],\n            'To' => [\n                [\n                    'Email' => \"passenger1@mailjet.com\",\n                    'Name' => \"passenger 1\"\n                ],\n                [\n                    'Email' => \"passenger2@mailjet.com\",\n                    'Name' => \"passenger 2\"\n                ]\n            ],\n            'Cc' => [\n                [\n                    'Email' => \"copilot@mailjet.com\",\n                    'Name' => \"Copilot\"\n                ]\n            ],\n            'Bcc' => [\n                [\n                    'Email' => \"air-traffic-control@mailjet.com\",\n                    'Name' => \"Air traffic control\"\n                ]\n            ],\n            'Subject' => \"Your email flight plan!\",\n            'TextPart' => \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\",\n            'HTMLPart' => \"<h3>Dear passenger 1, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\"\n        ]\n    ]\n];\n$response = $mj->post(Resources::$Email, ['body' => $body]);\n$response->success() && var_dump($response->getData());\n?>\n","lang":"php"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Node.js","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"/**\n *\n * This call sends a message to one recipient.\n *\n */\nconst mailjet = require ('node-mailjet')\n\t.connect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE)\nconst request = mailjet\n\t.post(\"send\", {'version': 'v3.1'})\n\t.request({\n\t\t\"Messages\":[\n\t\t\t\t{\n\t\t\t\t\t\t\"From\": {\n\t\t\t\t\t\t\t\t\"Email\": \"pilot@mailjet.com\",\n\t\t\t\t\t\t\t\t\"Name\": \"Mailjet Pilot\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"To\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"passenger1@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"passenger 1\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"passenger2@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"passenger 2\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Cc\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"copilot@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"Copilot\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Bcc\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"air-traffic-control@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"Air traffic control\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Subject\": \"Your email flight plan!\",\n\t\t\t\t\t\t\"TextPart\": \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\",\n\t\t\t\t\t\t\"HTMLPart\": \"<h3>Dear passenger 1, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\"\n\t\t\t\t}\n\t\t]\n\t})\nrequest\n\t.then((result) => {\n\t\tconsole.log(result.body)\n\t})\n\t.catch((err) => {\n\t\tconsole.log(err.statusCode)\n\t})\n","lang":"javascript"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ruby","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"# This call sends a message to one recipient.\nrequire 'mailjet'\nMailjet.configure do |config|\n  config.api_key = ENV['MJ_APIKEY_PUBLIC']\n  config.secret_key = ENV['MJ_APIKEY_PRIVATE']  \n  config.api_version = \"v3.1\"\nend\nvariable = Mailjet::Send.create(messages: [{\n    'From'=> {\n        'Email'=> 'pilot@mailjet.com',\n        'Name'=> 'Mailjet Pilot'\n    },\n    'To'=> [\n        {\n            'Email'=> 'passenger1@mailjet.com',\n            'Name'=> 'passenger 1'\n        },\n        {\n            'Email'=> 'passenger2@mailjet.com',\n            'Name'=> 'passenger 2'\n        }\n    ],\n    'Cc'=> [\n        {\n            'Email'=> 'copilot@mailjet.com',\n            'Name'=> 'Copilot'\n        }\n    ],\n    'Bcc'=> [\n        {\n            'Email'=> 'air-traffic-control@mailjet.com',\n            'Name'=> 'Air traffic control'\n        }\n    ],\n    'Subject'=> 'Your email flight plan!',\n    'TextPart'=> 'Dear passenger 1, welcome to Mailjet! May the delivery force be with you!',\n    'HTMLPart'=> '<h3>Dear passenger 1, welcome to <a href=\\'https://www.mailjet.com/\\'>Mailjet</a>!</h3><br />May the delivery force be with you!'\n}]\n)\np variable.attributes['Messages']\n","lang":"ruby"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"\"\"\nThis call sends a message to one recipient.\n\"\"\"\nfrom mailjet_rest import Client\nimport os\napi_key = os.environ['MJ_APIKEY_PUBLIC']\napi_secret = os.environ['MJ_APIKEY_PRIVATE']\nmailjet = Client(auth=(api_key, api_secret), version='v3.1')\ndata = {\n  'Messages': [\n\t\t\t\t{\n\t\t\t\t\t\t\"From\": {\n\t\t\t\t\t\t\t\t\"Email\": \"pilot@mailjet.com\",\n\t\t\t\t\t\t\t\t\"Name\": \"Mailjet Pilot\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"To\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"passenger1@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"passenger 1\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"passenger2@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"passenger 2\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Cc\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"copilot@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"Copilot\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Bcc\": [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"Email\": \"air-traffic-control@mailjet.com\",\n\t\t\t\t\t\t\t\t\t\t\"Name\": \"Air traffic control\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"Subject\": \"Your email flight plan!\",\n\t\t\t\t\t\t\"TextPart\": \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\",\n\t\t\t\t\t\t\"HTMLPart\": \"<h3>Dear passenger 1, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\"\n\t\t\t\t}\n\t\t]\n}\nresult = mailjet.send.create(data=data)\nprint result.status_code\nprint result.json()\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Java","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"package com.my.project;\nimport com.mailjet.client.errors.MailjetException;\nimport com.mailjet.client.errors.MailjetSocketTimeoutException;\nimport com.mailjet.client.MailjetClient;\nimport com.mailjet.client.MailjetRequest;\nimport com.mailjet.client.MailjetResponse;\nimport com.mailjet.client.ClientOptions;\nimport com.mailjet.client.resource.Emailv31;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\npublic class MyClass {\n    /**\n     * This call sends a message to one recipient.\n     */\n    public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {\n      MailjetClient client;\n      MailjetRequest request;\n      MailjetResponse response;\n      client = new MailjetClient(System.getenv(\"MJ_APIKEY_PUBLIC\"), System.getenv(\"MJ_APIKEY_PRIVATE\"), new ClientOptions(\"v3.1\"));\n      request = new MailjetRequest(Emailv31.resource)\n\t\t\t.property(Emailv31.MESSAGES, new JSONArray()\n                .put(new JSONObject()\n                    .put(Emailv31.Message.FROM, new JSONObject()\n                        .put(\"Email\", \"pilot@mailjet.com\")\n                        .put(\"Name\", \"Mailjet Pilot\"))\n                    .put(Emailv31.Message.TO, new JSONArray()\n                        .put(new JSONObject()\n                            .put(\"Email\", \"passenger1@mailjet.com\")\n                            .put(\"Name\", \"passenger 1\"))\n                        .put(new JSONObject()\n                            .put(\"Email\", \"passenger2@mailjet.com\")\n                            .put(\"Name\", \"passenger 2\")))\n                    .put(Emailv31.Message.CC, new JSONArray()\n                        .put(new JSONObject()\n                            .put(\"Email\", \"copilot@mailjet.com\")\n                            .put(\"Name\", \"Copilot\")))\n                    .put(Emailv31.Message.BCC, new JSONArray()\n                        .put(new JSONObject()\n                            .put(\"Email\", \"air-traffic-control@mailjet.com\")\n                            .put(\"Name\", \"Air traffic control\")))\n                    .put(Emailv31.Message.SUBJECT, \"Your email flight plan!\")\n                    .put(Emailv31.Message.TEXTPART, \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\")\n                    .put(Emailv31.Message.HTMLPART, \"<h3>Dear passenger 1, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\")));\n      response = client.post(request);\n      System.out.println(response.getStatus());\n      System.out.println(response.getData());\n    }\n}\n","lang":"java"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"/*\nThis call sends a message to one recipient.\n*/\npackage main\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\tmailjet \"github.com/mailjet/mailjet-apiv3-go\"\n)\nfunc main () {\n\tmailjetClient := NewMailjetClient(os.Getenv(\"MJ_APIKEY_PUBLIC\"), os.Getenv(\"MJ_APIKEY_PRIVATE\"))\n\tmessagesInfo := []mailjet.InfoMessagesV31 {\n      mailjet.InfoMessagesV31{\n        From: &mailjet.RecipientV31{\n          Email: \"pilot@mailjet.com\",\n          Name: \"Mailjet Pilot\",\n        },\n        To: &mailjet.RecipientsV31{\n          mailjet.RecipientV31 {\n            Email: \"passenger1@mailjet.com\",\n            Name: \"passenger 1\",\n          },\n          mailjet.RecipientV31 {\n            Email: \"passenger2@mailjet.com\",\n            Name: \"passenger 2\",\n          },\n        },\n        Cc: &mailjet.RecipientsV31{\n          mailjet.RecipientV31 {\n            Email: \"copilot@mailjet.com\",\n            Name: \"Copilot\",\n          },\n        },\n        Bcc: &mailjet.RecipientsV31{\n          mailjet.RecipientV31 {\n            Email: \"air-traffic-control@mailjet.com\",\n            Name: \"Air traffic control\",\n          },\n        },\n        Subject: \"Your email flight plan!\",\n        TextPart: \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\",\n        HTMLPart: \"<h3>Dear passenger 1, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\",\n      },\n    }\n\tmessages := mailjet.MessagesV31{Info: messagesInfo }\n\tres, err := m.SendMailV31(&messages)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Printf(\"Data: %+v\\n\", res)\n}\n","lang":"go"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"C#","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"using Mailjet.Client;\nusing Mailjet.Client.Resources;\nusing System;\nusing Newtonsoft.Json.Linq;\nnamespace Mailjet.ConsoleApplication\n{\n   class Program\n   {\n      /// <summary>\n      /// This call sends a message to one recipient.\n      /// </summary>\n      static void Main(string[] args)\n      {\n         RunAsync().Wait();\n      }\n      static async Task RunAsync()\n      {\n         MailjetClient client = new MailjetClient(Environment.GetEnvironmentVariable(\"MJ_APIKEY_PUBLIC\"), Environment.GetEnvironmentVariable(\"MJ_APIKEY_PRIVATE\"))\n         {\n            Version = ApiVersion.V3_1,\n         };\n         MailjetRequest request = new MailjetRequest\n         {\n            Resource = Send.Resource,\n         }\n            .Property(Send.Messages, new JArray {\n                new JObject {\n                 {\"From\", new JObject {\n                  {\"Email\", \"pilot@mailjet.com\"},\n                  {\"Name\", \"Mailjet Pilot\"}\n                  }},\n                 {\"To\", new JArray {\n                  new JObject {\n                   {\"Email\", \"passenger1@mailjet.com\"},\n                   {\"Name\", \"passenger 1\"}\n                   },\n                  new JObject {\n                   {\"Email\", \"passenger2@mailjet.com\"},\n                   {\"Name\", \"passenger 2\"}\n                   }\n                  }},\n                 {\"Cc\", new JArray {\n                  new JObject {\n                   {\"Email\", \"copilot@mailjet.com\"},\n                   {\"Name\", \"Copilot\"}\n                   }\n                  }},\n                 {\"Bcc\", new JArray {\n                  new JObject {\n                   {\"Email\", \"air-traffic-control@mailjet.com\"},\n                   {\"Name\", \"Air traffic control\"}\n                   }\n                  }},\n                 {\"Subject\", \"Your email flight plan!\"},\n                 {\"TextPart\", \"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!\"},\n                 {\"HTMLPart\", \"<h3>Dear passenger 1, welcome to <a href=\\\"https://www.mailjet.com/\\\">Mailjet</a>!</h3><br />May the delivery force be with you!\"}\n                 }\n                });\n         MailjetResponse response = await client.PostAsync(request);\n         if (response.IsSuccessStatusCode)\n         {\n            Console.WriteLine(string.Format(\"Total: {0}, Count: {1}\\n\", response.GetTotal(), response.GetCount()));\n            Console.WriteLine(response.GetData());\n         }\n         else\n         {\n            Console.WriteLine(string.Format(\"StatusCode: {0}\\n\", response.StatusCode));\n            Console.WriteLine(string.Format(\"ErrorInfo: {0}\\n\", response.GetErrorInfo()));\n            Console.WriteLine(response.GetData());\n            Console.WriteLine(string.Format(\"ErrorMessage: {0}\\n\", response.GetErrorMessage()));\n         }\n      }\n   }\n}\n","lang":"csharp"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-response-1","__idx":5},"children":["API response"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"Messages\": [\n    {\n      \"Status\": \"success\",\n      \"To\": [\n        {\n          \"Email\": \"passenger1@mailjet.com\",\n          \"MessageUUID\": \"123\",\n          \"MessageID\": 456,\n          \"MessageHref\": \"https://api.mailjet.com/v3/message/456\"\n        },\n        {\n          \"Email\": \"passenger2@mailjet.com\",\n          \"MessageUUID\": \"124\",\n          \"MessageID\": 457,\n          \"MessageHref\": \"https://api.mailjet.com/v3/message/457\"\n        }\n      ],\n      \"Cc\": [\n        {\n          \"Email\": \"copilot@mailjet.com\",\n          \"MessageUUID\": \"125\",\n          \"MessageID\": 458,\n          \"MessageHref\": \"https://api.mailjet.com/v3/message/458\"\n        }\n      ],\n      \"Bcc\": [\n        {\n          \"Email\": \"air-traffic-control@mailjet.com\",\n          \"MessageUUID\": \"126\",\n          \"MessageID\": 459,\n          \"MessageHref\": \"https://api.mailjet.com/v3/message/459\"\n        }\n      ]\n    }\n  ]\n}\n"},"children":[]}]},"headings":[{"value":"Send a basic email","id":"send-a-basic-email","depth":1},{"value":"Required message properties","id":"required-message-properties","depth":2},{"value":"Example: one recipient","id":"example-one-recipient","depth":2},{"value":"API response","id":"api-response","depth":3},{"value":"Example: multiple recipients with Cc and Bcc","id":"example-multiple-recipients-with-cc-and-bcc","depth":2},{"value":"API response","id":"api-response-1","depth":3}],"frontmatter":{"title":"Mailjet Send API v3.1","seo":{"description":"Send a basic transactional email with Mailjet Send API v3.1: build a Messages array with From, To, Subject, and HTMLPart, then POST to the v3.1 endpoint.","priority":0.8,"title":"Send a basic email"}},"lastModified":"2026-08-26T10:53:57.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/send-api-v31/send-basic-email","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}