MailSpecto
Email verification 6 min read

How to check whether an email address is valid

We explain every stage of validation: from regular expressions and MX records to detecting disposable domains and the limits of SMTP tests. You will learn what can be checked without sending a message, and what cannot be checked at all.

MailSpecto Engineering Team

Mail infrastructure and deliverability

Syntax RFC 5322 DNS / MX MX lookup SMTP RCPT TO, no DATA Result mailbox_exists

1. "Valid" means three things

Asking whether an email address is valid really means asking three different questions:

  1. Is the address written correctly? That is about syntax: the @ sign, allowed characters, length.
  2. Can the domain receive mail? That is about DNS: does the domain exist and does it have a mail server.
  3. Does this specific mailbox exist? Only the recipient's mail server can answer that.

The address [email protected] can have perfect syntax, and company.com can have working MX records, and still there may be no john.smith mailbox. That is why reliable verification goes through all three levels and states plainly what it learned at each one.

2. Syntax: a regular expression is only the start

The formal rules for writing an address are set out in RFC 5321 and RFC 5322. They are more permissive than most people think: they allow quoted local parts and characters such as +, ! and #. Expressing the whole RFC in one regular expression is unreadable and, in practice, unnecessary.

In a form, a simple and deliberately loose filter is enough to catch obvious mistakes (no @, spaces, no dot in the domain):

^[^\s@]+@[^\s@]+\.[^\s@]+$

Real syntax validation happens later and also checks things a regular expression cannot see:

  • the local part (before the @) has at most 64 characters, the whole address at most 254;
  • the domain is made of valid labels (no double dots, no hyphen at the start or end of a label);
  • domains with non-ASCII characters (e.g. müller.de) are converted to ASCII (punycode), because that is the only form DNS understands;
  • plus addresses ([email protected]) are valid and should not be rejected.

Do not "fix" the address for the user

Removing dots or the part after the plus only works with some providers (Gmail, for example). Elsewhere it is a completely different mailbox. Verification may suggest a correction, but it should never silently change the address.

3. Domain and DNS: does anyone receive mail here?

Once the syntax is fine, we look the domain up in DNS:

  • Does the domain exist? An NXDOMAIN answer means there is no such domain, so the address is invalid.
  • MX records point to the servers that accept mail for the domain. Their presence is the strongest signal DNS can give.
  • No MX does not always mean no mail. Under RFC 5321 the sending server may then deliver to the domain's A or AAAA record (the so-called implicit MX). It is rare, but valid.
  • Null MX (MX 0 ., RFC 7505) is an explicit statement that "this domain does not accept mail". An address in such a domain is invalid.
$ dig +short MX company.com
10 mx1.company.com.
20 mx2.company.com.

An important distinction: a DNS timeout or a DNS server failure (SERVFAIL) does not mean the address is bad. It is a temporary problem. We mark such a result as undecided, and it is worth checking again rather than removing the address from your list.

4. Risk signals: valid, but doubtful

Some addresses pass syntax and DNS and still do not belong in a contact list:

  • Disposable domains give out a mailbox for a few minutes or hours. Signing up with one usually means someone does not want to hear from you.
  • Typos in the domain, such as gmial.com instead of gmail.com or hotmail.con instead of hotmail.com. The best moment to suggest a correction is while the user is still in the form.
  • Role-based addresses, such as office@, contact@, info@. They are valid and often needed in B2B, but several people read them, or nobody does, so marketing campaigns treat them with more care.

5. SMTP: asking about the specific mailbox

The only way to learn anything about the mailbox itself without sending a message is to start a conversation with the recipient's mail server and stop it before the content:

EHLO probe.example
MAIL FROM:<verify@example>
RCPT TO:<[email protected]>
550 5.1.1 User unknown
QUIT

A 250 reply to RCPT TO means the server would accept a message for this address, and 550 5.1.1 means there is no such mailbox. The DATA command is never sent, so no message reaches the recipient.

It sounds simple, but the method has real limits worth knowing:

  • Catch-all domains accept every address, including non-existent ones. A 250 then proves nothing. That is why we also check a random control address for every domain: if it is accepted too, the domain is catch-all.
  • Greylisting is a deliberate delay: the server replies with a 4xx code and asks you to retry in a few minutes. It is not a rejection, just a signal to try later.
  • Servers that do not reveal whether a mailbox exists accept every address during the conversation and reject non-existent ones only after accepting the message. Some hosting providers and company servers work this way.
  • Protection against probing: large providers limit the number of queries and block IP addresses that send too many.

An honest verifier says "I don't know" in these cases instead of guessing. "Domain accepts mail" or "catch-all" is valuable information, but it is not proof that the mailbox exists.

6. How to read a verification result

This is how MailSpecto splits results:

StatusWhat we knowWhat to do
mailbox_existsThe recipient's server confirmed the mailboxSend
catch_allThe domain accepts every addressSend with caution, watch bounces
domain_accepts_mailDNS and MX work, the mailbox is not confirmedSend with caution
riskyDisposable or a likely typoCheck risk_signals and any suggestion
invalidBad syntax, no domain, Null MX or no mailboxDo not send
unknownCould not be decided (e.g. DNS did not answer)Check again later

7. Checklist

  1. Use a simple syntax filter in forms and suggest corrections for domain typos.
  2. Before saving an address, check DNS: the domain exists, MX, implicit MX and Null MX.
  3. Reject disposable domains wherever you need a lasting contact.
  4. Verify mailboxes over SMTP without sending a message, and treat catch-all as its own category.
  5. Re-check temporary results (DNS timeouts, greylisting) instead of removing the addresses.
  6. Before a large campaign, verify the whole list, not just new addresses.

Keep your contact list clean

Verify email addresses before you send, and explore our upcoming SPF/DKIM/DMARC diagnostics module.

Try MailSpecto

MailSpecto Engineering Team

We build tools for email address verification, deliverability monitoring and mail infrastructure security diagnostics for companies in Poland and Europe.

Related articles

Email verification

MX record – how to check it and set it up correctly

How the MX record works, how to check it, what priorities, implicit MX and Null MX mean, and the most common mistakes.

Read article →
Email verification

Role-based addresses (office@, info@) in B2B – send or not?

What role-based addresses are, why they are risky in campaigns and when to keep them in B2B.

Read article →
Email verification

Email verification in online stores – fewer failed orders

How typos in the checkout address end in undelivered invoices, and how to catch them in the cart without losing customers.

Read article →