← All problems and solutions

How do I validate an email address (MX records, disposable domains) before sending?

Check syntax, then look up the domain's MX records, then compare the domain against a disposable-provider list, and flag role addresses such as info@ or support@. None of this proves a mailbox exists; only a confirmation email does. Do not reject valid plus-addresses, and treat DNS timeouts as inconclusive rather than invalid.

By AISend. Updated . Also as markdown.

Why it happens

Bounces come from addresses that do not exist: typos (gmial.com), made-up addresses, domains that no longer accept mail, and throwaway inboxes that vanish after ten minutes. Receiving servers and email providers see a high bounce rate or many complaints as a sign of a careless sender and put your sending reputation, and sometimes the account itself, at risk. Cheap checks before you send catch the most obvious cases.

How to recognise your case: bounces with 'user unknown' or 'domain not found' codes, sign-ups from addresses at disposable domains that never confirm, or a form that accepts anything with an at-sign.

What a check can and cannot tell you is the important part. These are the layers, from cheapest to most certain:

CheckWhat it provesWhat it cannot prove
SyntaxThe string can be an address.That anyone owns it.
MX lookupThe domain publishes mail servers, or (per RFC 5321) has an address record to fall back on.That a given mailbox on that domain exists.
Disposable-domain listThe domain belongs to a known throwaway provider.Anything about new or unlisted throwaway domains; lists are never complete.
Role-address checkThe local part looks like a shared mailbox (info, support, admin).That role addresses are bad: they are often deliverable.
SMTP probeSome servers say 'no such user' at RCPT TO.Catch-all domains accept everything, and many servers refuse to answer or greylist probes.
Confirmation emailThe person controls the inbox right now.Nothing is left to prove; this is the only real verification.

How to fix it (works with any email provider)

  1. Normalise and check the syntax, loosely. Trim whitespace, then require one at-sign, a non-empty local part, a domain with at least one dot, and a total length of at most 254 characters (RFC 5321 limits a path to 256 octets including the angle brackets). Keep the regex permissive. Strict patterns reject real addresses; the confirmation email catches the rest. Do not lowercase the local part if you will email it: RFC 5321 says the local part must be treated as case sensitive, although nearly all providers ignore case.
  2. Do not reject plus-addresses and other valid characters. Addresses like jane+orders@example.com, first.last@example.com and o'brien@example.com are valid and common. Plus-addressing is how many people filter mail and track who sold their address. If your validator rejects them, you lose real customers and nothing is gained.
  3. Look up the MX records. From a shell, dig MX example.com +short or nslookup -type=MX example.com returns the mail servers and their priorities. An empty answer with NOERROR means no MX records; NXDOMAIN means the domain does not exist. In Node, dns.promises.resolveMx(domain) returns objects with priority and exchange. RFC 5321 says that if there are no MX records the sender falls back to the domain's address record, so a domain with only an A record can still receive mail; treat 'no MX and no A or AAAA' as invalid.
    # Shell
    dig MX example.com +short
    nslookup -type=MX example.com
  4. Treat DNS failures as inconclusive, not invalid. A lookup that times out or returns SERVFAIL says nothing about the address. Only definitive answers (domain does not exist, no MX and no address record) should reject. Cache MX results for a while, because the answer rarely changes and lookups add latency to a signup form.
    import { promises as dns } from "node:dns";
    
    const FORMAT = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    const DISPOSABLE = new Set(["mailinator.com", "10minutemail.com", "guerrillamail.com"]); // load a maintained list in production
    const ROLE = new Set(["info", "admin", "support", "postmaster", "webmaster", "abuse", "noreply", "no-reply", "sales", "billing"]);
    
    export async function checkAddress(input) {
      const email = input.trim();
      if (email.length > 254 || !FORMAT.test(email)) return { verdict: "invalid", reason: "syntax" };
    
      const at = email.lastIndexOf("@");
      const local = email.slice(0, at);
      const domain = email.slice(at + 1).toLowerCase();
    
      if (DISPOSABLE.has(domain)) return { verdict: "invalid", reason: "disposable" };
    
      try {
        const mx = await dns.resolveMx(domain);
        if (mx.length === 0) throw Object.assign(new Error("no MX"), { code: "ENODATA" });
      } catch (err) {
        if (err.code === "ENOTFOUND" || err.code === "ENODATA") {
          // RFC 5321: with no MX, mail goes to the domain's A/AAAA record.
          const hasAddress = await dns.resolve4(domain).then((a) => a.length > 0).catch(() => false);
          if (!hasAddress) return { verdict: "invalid", reason: "no mail servers" };
        } else {
          return { verdict: "unknown", reason: "dns error: " + err.code }; // do not block on a DNS blip
        }
      }
      return { verdict: "ok", role: ROLE.has(local.toLowerCase()) };
    }
  5. Compare the domain against a disposable-domain list. Use a maintained, regularly updated list, and match the registrable domain exactly rather than by substring. New throwaway domains appear constantly, so a list reduces abuse; it does not eliminate it. Decide your policy in advance: block at signup, or allow but flag.
  6. Flag role addresses, do not block them. info@, support@, billing@ and similar are usually real, shared mailboxes. They matter for marketing (many people read them, few consent), but for a receipt or an invoice sent to a company, they are often the right place. Flag and let the product decide.
  7. Do not try to verify the mailbox yourself at scale. SMTP probing (connecting and issuing RCPT TO) is unreliable. Catch-all domains accept every address, and greylisting, rate limiting and blocklists mean your probing IP can be blocked or learn nothing. Use it, if at all, as a weak signal and fail open on timeouts or 4xx responses.
  8. Verify by confirmation email for anything that matters. Send one message with a single-use, expiring link and mark the address verified only when it is clicked. This is the only check that proves the person controls the inbox, and it also makes sure the user consented. Until it is clicked, send nothing else to that address.

When to use AISend

AISend validates addresses in two ways. The first is an explicit check: POST /api/v1/email-validation/validate with { "email": "user@example.com" } (or { "emails": [...] } with up to 100 addresses), and the validate_email tool over MCP, which calls it. It checks syntax, whether the domain has MX records, whether the domain is on its disposable-domain list, and whether the local part is a role name from a fixed list (info, admin, support, noreply, sales, billing, and similar). The response has valid, a checks object (format, mx, disposable, role, catchAll) and a risk of low, medium or high. valid is true only when the format is right, an MX exists and the domain is not disposable. A role address is valid but medium risk.

What it does not do: the catchAll field is not determined today and returns null, it does not probe the mailbox, and a domain with no MX record fails even though RFC 5321 would fall back to an address record. Each address counts once against the account's monthly validation quota (a batch of 50 counts as 50), and the quota depends on the plan; see /pricing. Over quota returns HTTP 429, and an account without a paid plan gets HTTP 402 once it is past its free test allowance. AISend needs a paid plan to send to your recipients or validate addresses (10 free test emails go to your own address).

The second is automatic: when you send through AISend, every recipient is screened before the message is accepted. Bad syntax, disposable domains and domains with no mail servers are rejected with HTTP 422 and never reach the mail provider, and an SMTP mailbox probe rejects only on a definite 5xx 'no such user' answer; timeouts and temporary errors let the message through. Addresses that bounced or complained before are also refused (suppression).

Use something else when you need a deliverability verdict on a purchased or scraped list (AISend is not for sending to such lists), when you need catch-all detection or mailbox-level verification from a dedicated verification vendor, or when a signup form needs an instant client-side syntax check (the regex above costs nothing). The confirmation email is always the final check, with any provider.

Copy-paste prompt for an AI assistant connected to AISend

Connect an assistant first (setup for ChatGPT, Claude, Cursor and Gemini CLI), then paste:

Assign to AISend: validate these customer addresses before I mail them: [paste addresses]. Use validate_email once per address and show me a table with each address, valid, risk, and which check failed (format, mx, disposable or role). Use list_domains first so I can see which domain I would send from. Do not send anything, and do not remove any address yourself. Show me what you did so I can approve which addresses to keep, and note that each validate_email call uses my monthly validation quota.

Frequently asked questions

Can I confirm that a mailbox exists without sending an email?

Not reliably. Some servers answer 'no such user' to an SMTP probe, but catch-all domains accept everything and many servers refuse to answer or greylist. A confirmation email with a single-use link is the only real proof.

Should I block role addresses like info@ and support@?

Usually not. They are often real shared mailboxes. Flag them, because they carry a higher risk of complaints for marketing mail, but they are fine for receipts, invoices and account notices to a company.

Why does my validator reject addresses with a plus sign?

Its pattern is too strict. Plus-addresses such as jane+orders@example.com are valid and common, and rejecting them loses real customers for no benefit. Loosen the syntax check and rely on the confirmation email.

What if the MX lookup times out?

Treat it as unknown, not invalid. A timeout or SERVFAIL is not evidence about the address. Retry once, cache definitive results, and let the confirmation email decide.

Does AISend's validate_email use up my quota?

Yes. Each address validated counts once against the account's monthly validation quota, whether it passes or fails. The sending-time recipient screening is separate and does not use that quota.

Sources

Related