MailKite
Get your API key
All guides Sending email

Send email with Mailjet

Transactional email is the mail your app sends one recipient at a time — receipts, password resets, magic links, notifications. This guide sends one through Mailjet, over both the API and SMTP, then shows the same send on MailKite.

What you'll need

  • A domain you control, with access to its DNS records.
  • An API key and Secret key from your Mailjet account.

Part 1 — Send with Mailjet

1. Authenticate your domain

So your mail passes authentication and lands in the inbox, add your sender domain under Account settings → Sender domains & addresses and publish the records Mailjet shows you — an SPF include and a DKIM key (both TXT), plus a DMARC policy:

DNS — yourdomain.com
Type   Name                              Value
TXT yourdomain.com v=spf1 include:spf.mailjet.com ?all
TXT mailjet._domainkey.yourdomain.com k=rsa; p=… (DKIM record shown in your dashboard)
TXT _dmarc.yourdomain.com v=DMARC1; p=none;

Mailjet shows the exact per-domain DKIM value in the dashboard — copy it from there.

2. Send over the API

POST to Mailjet's Send API v3.1 with HTTP Basic auth — your API key as the username, Secret key as the password. The From address must be on the domain you just authenticated:

send
curl -X POST https://api.mailjet.com/v3.1/send \
--user "$MJ_APIKEY:$MJ_SECRETKEY" \
-H "Content-Type: application/json" \
-d '{
"Messages": [{
"From": { "Email": "hello@yourdomain.com", "Name": "MyApp" },
"To": [{ "Email": "ada@example.com", "Name": "Ada" }],
"Subject": "Your invoice #1042",
"TextPart": "Thanks! Your receipt is attached.",
"HTMLPart": "<p>Thanks! Your receipt is attached.</p>"
}]
}'
response
200 OK
{ "Messages": [{
"Status": "success",
"To": [{ "Email": "ada@example.com",
"MessageID": 1234567890,
"MessageUUID": "abc123-…" }]
}] }

3. Or send over SMTP

Prefer SMTP? Point your app at Mailjet's relay. The username is your API key and the password is your Secret key, not your account login:

smtp
Host:      in-v3.mailjet.com
Port: 587 # TLS (also 465 for SSL, or 2525)
Username: <API key> # from SMTP and SEND API settings
Password: <Secret key> # not your account password
From: hello@yourdomain.com

That's a transactional send on Mailjet: authenticate the domain, then call the API or the SMTP relay.

Part 2 — The same, on MailKite

When we built sending into MailKite, we wanted three things to be true: one set of DNS records, one API key that works for both HTTP and SMTP, and a body you don't have to nest. Here's the same message.

1. Authenticate your domain

Publish three TXT records — SPF, a MailKite DKIM key, and DMARC. The same domain also receives mail once its MX points at MailKite:

DNS — yourdomain.com
Type   Name                              Value
TXT yourdomain.com v=spf1 include:mailkite.dev ~all
TXT mailkite._domainkey.yourdomain.com v=DKIM1; k=rsa; p=…
TXT _dmarc.yourdomain.com v=DMARC1; p=none;

The exact DKIM value is shown in the dashboard; MailKite verifies the records for you over DNS.

2. Send over the API

One POST /v1/send with a flat from/to/ subject/html body. A 202 means it's queued:

Pick your language in the card — the dashboard and the AI assistant do the same send, and every SDK takes the same fields:

send
import { MailKite } from "mailkite";

const mk = new MailKite(process.env.MAILKITE_API_KEY);

const { id, status } = await mk.send({
from: "hello@myapp.ai",
to: "ada@example.com",
subject: "Your invoice #1042",
html: "<p>Thanks! Receipt attached.</p>",
});
Install Docs →
response
202 Accepted
{ "id": "msg_2Hk9…", "status": "queued" }

3. Or send over SMTP

The same key is your SMTP password — no separate credential to generate:

smtp
import nodemailer from "nodemailer";

const tx = nodemailer.createTransport({
host: "smtp.mailkite.dev",
port: 587, // STARTTLS · use 465 for implicit TLS
auth: {
user: "mailkite", // any username works
pass: process.env.MAILKITE_API_KEY, // your mk_live_… key
},
});

await tx.sendMail({
from: "hello@myapp.ai", // an address on a verified domain
to: "ada@example.com",
subject: "Your invoice #1042",
html: "<p>Thanks! Receipt attached.</p>",
});

See Send API and SMTP relay for the full reference — attachments, headers, and delivery events.

A little about MailKite

MailKite is programmable email for developers and AI agents. One API key and one set of DNS records cover both directions: send with a single POST (or the SMTP relay), and the same verified domain receives replies as a signed webhook of clean JSON. Behind the send, MailKite routes across multiple providers to keep you in the inbox — and any address can be handed to an agent that reads and replies on its own. Sending and receiving are on the free tier.

Next: the Send API for attachments and delivery tracking, or the Quickstart to get a verified domain and API key.