Marketing & email
Verify emails before adding Mailjet contacts or sending
Verify an address before it joins a Mailjet contact list with a stored email_status property, and filter recipients before each call to Mailjet's Send API v3.1.
Updated 2026-11-26
This recipe checks addresses at the two moments they meet Mailjet. Before a signup joins a contact list, your backend verifies the address and stores the result in an email_status contact property. Before each call to the Send API, a filter drops recipients that cannot receive mail. There is no native Qelka app for Mailjet: the code below uses Mailjet's official Node.js library, node-mailjet, and runs on your server.
Why both places: the list check protects your campaigns, the send check protects transactional mail to addresses that never went through a list, such as invites or imported customers. Mail to an address that does not exist bounces, and mailbox providers rate your domain by how much of your mail bounces. See Email bounces explained.
What you need
- A Mailjet account, its API key and secret key, a validated sender address, and the ID of the contact list that signups join.
- Node.js 18 or later, and
npm install node-mailjet @qelka/sdk. - A Qelka API key. A
sk_test_key returns simulated results and never spends credits: see Test mode. - Environment variables
MJ_APIKEY_PUBLIC,MJ_APIKEY_PRIVATE,MAILJET_LIST_IDandQELKA_API_KEY. Keep all of them on the server.
Steps
1. Create the contact property once
import Mailjet from 'node-mailjet'
const mailjet = new Mailjet({
apiKey: process.env.MJ_APIKEY_PUBLIC,
apiSecret: process.env.MJ_APIKEY_PRIVATE,
})
const result = await mailjet.post('contactmetadata').request({
Datatype: 'str',
Name: 'email_status',
NameSpace: 'static',
})
console.log(result.body)
A static property keeps one value, which each update replaces. Run this once; a second run fails because the name already exists.
2. Verify the address
import { ApiConnectionError, ApiError, Client } from '@qelka/sdk'
const verifier = new Client({ apiKey: process.env.QELKA_API_KEY, timeoutMs: 15000 })
export async function checkAddress(email, mode = 'full') {
try {
return await verifier.email.verify({ email, mode })
} catch (error) {
if (error instanceof ApiError) {
console.warn(`email check skipped: ${error.type} request ${error.requestId}`)
} else if (error instanceof ApiConnectionError) {
console.warn(`email check skipped: ${error.message}`)
} else {
throw error
}
return { status: 'unchecked', reason: null, did_you_mean: null }
}
}
full mode asks the recipient's mail server about the mailbox, which can take several seconds, hence the 15-second timeout. In a signup form where the person waits, pass 'fast': the syntax, DNS and list checks still catch typos, dead domains and disposable inboxes, and the rest comes back unknown with smtp_not_checked. Any API problem returns unchecked and never blocks the flow.
3. Add the contact to the list with its status
import Mailjet from 'node-mailjet'
import { checkAddress } from './check-address.js'
const mailjet = new Mailjet({
apiKey: process.env.MJ_APIKEY_PUBLIC,
apiSecret: process.env.MJ_APIKEY_PRIVATE,
options: { timeout: 15000 },
})
export async function subscribe(rawEmail, name) {
const email = rawEmail.trim()
const check = await checkAddress(email, 'fast')
if (check.status === 'undeliverable') {
return { ok: false, suggestion: check.did_you_mean }
}
if (check.reason === 'disposable') {
return { ok: false, suggestion: null }
}
try {
await mailjet
.post('contactslist')
.id(Number(process.env.MAILJET_LIST_ID))
.action('managecontact')
.request({
Email: email,
Name: name,
Action: 'addnoforce',
Properties: { email_status: check.status },
})
} catch (error) {
console.error(`Mailjet answered ${error.statusCode}`)
throw error
}
return { ok: true, suggestion: null }
}
The form shows "Did you mean" with suggestion when the address is refused. Disposable inboxes are refused here because a newsletter needs a lasting address; drop that branch if you prefer to accept them. Because the signup check runs in fast mode, most good addresses arrive as unknown: run a full check on the new contacts later, from a job, and update email_status with Mailjet's contact data call, as the library's README shows with put('contactdata').
4. Filter recipients before sending
For transactional mail, check the stored status of each recipient, or verify on the spot if you have none, and send only to the rest:
import Mailjet from 'node-mailjet'
import { checkAddress } from './check-address.js'
const mailjet = new Mailjet({
apiKey: process.env.MJ_APIKEY_PUBLIC,
apiSecret: process.env.MJ_APIKEY_PRIVATE,
options: { timeout: 15000 },
})
export async function sendWelcome(recipients) {
const messages = []
for (const recipient of recipients) {
const status = recipient.emailStatus ?? (await checkAddress(recipient.email)).status
if (status === 'undeliverable') {
console.info(`send skipped: ${recipient.email} is undeliverable`)
continue
}
messages.push({
From: { Email: 'hello@yourdomain.example', Name: 'Your team' },
To: [{ Email: recipient.email, Name: recipient.name }],
Subject: 'Welcome aboard',
TextPart: `Hi ${recipient.name}, your account is ready.`,
})
}
if (messages.length === 0) return []
const result = await mailjet.post('send', { version: 'v3.1' }).request({ Messages: messages })
for (const message of result.body.Messages) {
if (message.Status !== 'success') console.error('Mailjet message failed', message.Errors)
}
return result.body.Messages
}
Replace the From address with your validated sender. Only undeliverable is skipped: risky, unknown and unchecked recipients get their transactional mail, because they asked for it and the address may well work.
5. Act on each status
email_status |
Meaning | Campaigns | Transactional |
|---|---|---|---|
deliverable |
The mail server accepted the mailbox | Send | Send |
undeliverable |
Bad syntax, no domain, no mail servers or a refused mailbox | Never added; remove if a re-check finds it | Skip |
risky |
A disposable inbox, a catch-all domain or a full mailbox | Send catch-all addresses in a separate, small segment; hold full mailboxes | Send |
unknown |
Not conclusive: fast mode, greylisting, a provider that does not answer checks | Send, re-check later, never delete | Send |
unchecked |
The API was not reached | Send, and re-check | Send |
The email reference explains each reason behind these statuses.
Handle errors and rate limits
Nothing is billed on errors. 401 and 403 mean a wrong or restricted key and 402 an empty balance; they end as unchecked here, so a sudden rise in unchecked contacts is your alert. The Qelka SDK retries 429 after Retry-After. A key allows 200 requests per 10 seconds, and each check costs 1 credit, so verify a large import with a bulk file check instead of one call per contact. Mailjet errors carry statusCode and are rethrown, so your queue can retry the send. See Errors and Rate limits.
Related
Frequently asked questions
Do I have to create the email_status property first?
Why does addnoforce matter?
Mailjet returned 200 but one message did not go out. Why?
More in Marketing & email
All integrationsPut this check in your product
Get an API key in under a minute. 100 free credits every month, no card required.
- 100 free credits a month
- No card
- Test keys spend nothing
- Cancel any time