Skip to content

Marketing & email

Verify emails before sending with Resend

Verify an address before your app sends to it with the Resend Node.js SDK, and before it becomes a Resend contact with an email_status property and a segment.

Updated 2026-11-26

This recipe adds an email check in two places of an app that sends with Resend. Before a send, a guard skips addresses known to be undeliverable. Before an address becomes a Resend contact for your broadcasts, it is verified and stored with an email_status property, and only addresses worth mailing join your segment. There is no native Qelka integration for Resend; this is server code with the official resend Node.js SDK.

Why it matters: Resend suppresses an address after it hard bounces, but the bounce has already reached the mailbox provider, and providers rate your domain by how much of your mail bounces. Typos in signup forms, invites and imported lists are the usual source. See Email bounces explained.

What you need

  • A Resend account with a verified sending domain and an API key.
  • For contacts: a segment for your newsletter, and a string contact property named email_status.
  • Node.js 18 or later, and npm install resend @qelka/sdk.
  • A Qelka API key. A sk_test_ key returns simulated results and never spends credits: see Test mode.
  • Environment variables RESEND_API_KEY, RESEND_SEGMENT_ID and QELKA_API_KEY, read on the server only.

Steps

1. Verify the address

javascript
import { ApiConnectionError, ApiError, Client } from '@qelka/sdk'

const verifier = new Client({ apiKey: process.env.QELKA_API_KEY, timeoutMs: 10000 })

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 whether the mailbox exists. The 10-second timeout keeps a slow server from holding your signup, and every API problem returns unchecked instead of throwing, so nobody is locked out because a check failed. Store status and reason on the user record.

2. Refuse typos at signup

In the signup handler, an undeliverable answer is a reason to ask again, not to create the account:

javascript
import { checkAddress } from './check-address.js'

export async function validateSignupEmail(email) {
  const check = await checkAddress(email.trim())
  if (check.status === 'undeliverable') {
    return {
      ok: false,
      message: check.did_you_mean ? `Did you mean ${check.did_you_mean}?` : 'This address cannot receive mail.',
    }
  }
  return { ok: true, emailStatus: check.status, emailReason: check.reason }
}

If 10 seconds is too long for your form, call checkAddress(email, 'fast') here: it still catches typos in the domain, domains that take no mail and disposable inboxes, and returns unknown with smtp_not_checked for the rest. Run the full check in a background job afterwards.

3. Guard every send

javascript
import { Resend } from 'resend'

const resend = new Resend(process.env.RESEND_API_KEY)

export async function sendToUser(user, { subject, html }) {
  if (user.emailStatus === 'undeliverable') {
    console.info(`send skipped: ${user.email} is undeliverable (${user.emailReason})`)
    return { sent: false }
  }

  const { data, error } = await resend.emails.send({
    from: 'Your team <hello@yourdomain.example>',
    to: [user.email],
    subject,
    html,
  })
  if (error) {
    console.error(`Resend send failed: ${error.name}: ${error.message}`)
    throw new Error(error.message)
  }
  return { sent: true, id: data.id }
}

Replace the sender with an address on your verified domain. The Resend SDK returns { data, error } instead of throwing, so the guard checks error and throws for your job queue to retry. Only undeliverable is skipped: risky, unknown and unchecked addresses still get the mail they asked for.

4. Add contacts for broadcasts

When someone opts in to your newsletter, create the contact with its status, and add it to the segment only when the address is worth mailing:

javascript
import { Resend } from 'resend'
import { checkAddress } from './check-address.js'

const resend = new Resend(process.env.RESEND_API_KEY)

export async function addNewsletterContact(rawEmail) {
  const email = rawEmail.trim()
  const check = await checkAddress(email)

  if (check.status === 'undeliverable') {
    return { ok: false, suggestion: check.did_you_mean }
  }

  const joinsSegment = check.reason !== 'disposable'
  const { data, error } = await resend.contacts.create({
    email,
    unsubscribed: false,
    properties: { email_status: check.status },
    ...(joinsSegment ? { segments: [{ id: process.env.RESEND_SEGMENT_ID }] } : {}),
  })
  if (error) {
    console.error(`Resend contact not created: ${error.name}: ${error.message}`)
    throw new Error(error.message)
  }
  return { ok: true, contactId: data.id }
}

The property lets you filter or build segments on email_status later, for example to re-check unknown contacts before a large broadcast.

5. Act on each status

status Meaning Transactional mail Broadcasts
deliverable The mail server accepted the mailbox Send Send
undeliverable Bad syntax, a domain that takes no mail, or a refused mailbox Skip; ask the person to fix the address Never added
risky A disposable inbox, a catch-all domain or a full mailbox Send Disposable inboxes stay out of the segment; send catch-all addresses with care; re-check full mailboxes
unknown The checks could not conclude Send Send. Never delete on this result; re-check later
unchecked The API was not reached Send Send, and re-check

The email reference explains each reason behind these statuses.

6. Test it

With a sk_test_ key, undeliverable@example.com comes back undeliverable, disposable@example.com risky and any other well-formed address deliverable: the part before the @ picks the result. Resend provides its own test recipients for the send side, such as delivered@resend.dev in its quick start.

Handle errors and rate limits

Nothing is billed on errors. 401 and 403 mean a wrong or restricted key, and 402 an empty balance: all end as unchecked, so count those records and alert yourself, or register a low-balance webhook. The Qelka SDK retries 429 after Retry-After. A key allows 200 requests per 10 seconds, and each check costs 1 credit. To bring an existing contact list in, verify it with a bulk file check first and import only the addresses you keep. See Errors and Rate limits.

Frequently asked questions

Doesn't Resend already stop sending to addresses that bounce?
It does after the fact. Resend puts an address on its suppression list after a hard bounce or a spam complaint and marks later emails to it as suppressed, across all the domains of your team. The bounce that put it there still counted against your sender reputation. Verifying first keeps the address from bouncing in the first place.
Audiences or segments: which one do I use for contacts?
Resend's current contacts API groups contacts in segments, and the Node.js SDK marks the older audienceId option as deprecated in favour of segments. If your code still passes audienceId, update the SDK and pass segments with the segment IDs instead.
Do I need to create the email_status property first?
Yes. Resend sets a property on a contact only if its key already exists and the value has the right type; otherwise the call returns an error. Create email_status once as a string property, in the Properties view of the Resend dashboard or with the contact properties API.

More in Marketing & email

All integrations

Put 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