Guides
Last updated
April 7, 2023

How can I do an SMTP and MX check?

Emma Jagger
Emma Jagger

Table of Contents:

Get your free
Email Validation
 API key now
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
START FOR FREE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required

Checking user-inputted data from a form is something that every web developer has to do for a majority of his projects.

Most of the time, this process is relatively simple, but there are certain types of data for which verification is more complex. It is the case, for example, with emails addresses, for which verification is critical, mostly because essential processes of business rely on emails addresses, such as authentication or marketing.

How to properly verify an email address?

For the majority of data, a simple syntax check is sufficient. For example, if you ask your user to create a new password, you can sufficiently check its length and if it contains numbers, letters and special characters.

The date data-type format verification is simple to perform since it consists of 3 groups of numbers. But to make sure that the date exists, you need an extra step to match it to a calendar.

The same is true for email addresses, for which a simple syntax check is not enough. An email address such as idonotexist@meneither.com is very likely to not exist, and your verification scripts must be able to detect it.

How does an email transit to your recipient's server?

Let's dwell for a few moments on email servers' basic functioning to illustrate the rest of this article.

When you send an email, your email client is configured to connect to your SMTP server. Your server will then need to determine which SMTP server to push your message to reach its recipient.

The part after the @ symbol determines the domain hosting your recipient's mailbox in an email address. Your SMTP server will query the target domain to check for its MX fields, which point to the mail servers for this domain.

The final step is to connect to the recipient's mail server and to transmit your message.

This article will review two methods to check the MX fields and SMTP server of a target domain, first manually to understand how this kind of procedure works, and then using a free tool. Checking SMTP and MX records is a particularly important part of validating and verifying emails.

How to check the MX records of a domain?

There are several methods to check MX records of a domain.

Google provides a free service for obtaining domain records. Connect your web browser to https://dns.google.com and enter the domain name to be verified, "google.com" for example. You will also need to enter the letters MX in the RR field, and here is the result:



{
"(...),
"Question": [
{
"name": "google.com.",
"type": 15
}
],
"Answer": [
{
"name": "google.com.",
"type": 15,
"TTL": 597,
"data": "30 alt2.aspmx.l.google.com."
},
{
"name": "google.com.",
"type": 15,
"TTL": 597,
"data": "50 alt4.aspmx.l.google.com."
},
(...)
]
}

On any Unix based computer, such as Linux and Mac OS distributions, it is possible to use the dig utility to get the information about a domain from the command line. Here is how:



$ dig google.com mx

(...)
;; QUESTION SECTION:
;google.com. IN MX

;; ANSWER SECTION:
google.com. 530 IN MX 50 alt4.aspmx.l.google.com.
google.com. 530 IN MX 30 alt2.aspmx.l.google.com.
(...)

Whichever method you use, you now know which mail servers, otherwise known as SMTP, are used by the domain name to receive emails.

Enter your email address to start
Need inspiration? Try
test@abstractapi.com
VALIDATE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Checking
5
Results for
email
Deliverability:
TEST
Free email:
TEST
Valid format:
TEST
Disposable email:
TEST
Valid SMTP:
TEST
Valid MX record:
TEST
Get free credits, more data, and faster results

How an email address that doesn't exist can ruin my business?

Mail servers do not only exchange messages between them; they also have several mechanisms to fight against spam. An email server that receives too many messages destined to non-existing domains can automatically report the emitting domain as a potential spamming source.

Once your domain name received multiple spam suspicion reports, you could be considered a spammer and your mail server could be blacklisted. The consequence is that most of your emails will be blocked by spam filters before they have a chance to reach your recipients' mailboxes.

There are several ways to reduce the risk of being blacklisted. The first and easiest mechanism to set-up is to implement an email address verification script which ensures that the recipient's domain exists and contains email servers.

Why not check the existence of the mailbox against the recipient's SMTP server?

Those who know the SMTP protocol might want to implement a verification script to send the recipient's mail server the VRFY command. The VRFY command allows you to verify a mailbox's existence on an SMTP server, which could have been convenient in our situation. Unfortunately, most SMTP servers do not respond correctly to the VRFY command, making it unusable.

What is the best method to verify MX fields and SMTP configuration?

The fastest and cheapest way is to use an API to verify the email address's domain configuration.

Abstract Email Verification API is free and easy to use. It provides information on the MX fields and the SMTP server and additional interesting data about an email address, in real-time.

To use it, you only need to create an account on the Abstract website. Then you are ready to use the API.

How to check the health of an SMTP server?

Once you have the names of the SMTP servers of the recipient's domain, you should check that its service is working.

The common way to do this is to use the telnet utility and connect to the SMTP port to check that the server responds. The SMTP port number is generally 25, and here is how to proceed:



$ telnet alt2.aspmx.l.google.com 25

Trying 2404:6800:4003:c06::1a...
Connected to alt2.aspmx.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP f18si9212169pgg.271 - gsmtp

We received a response from the SMTP server and can deduct for sure that it's up and running.

Note that depending on the server configuration, it is possible that the server is not listening on port 25 but ports 465, 587, or 2525.

How to automate checks on MX records and SMTP servers?

Even if these manual methods allow you to obtain results in a few minutes, it is inconceivable to proceed this way when you have a multitude of email addresses to be checked.

It is then necessary to use a service capable of providing this information automatically and quickly.

Abstract provides an API that allows you to check MX records and SMTP servers from an email address for free. Besides, the analysis data that the Abstract API provides contains a lot of additional information about the recipient's email address and its configuration.

Register on the Abstract site with your email address and your chosen password, which does not require a credit card. You are ready to use the API with a simple GET call. Here is an example of use with curl from the command line:



$ curl "https://emailvalidation.abstractapi.com/v1/?api_key=YOUR_API_KEY&email=johnsmith@gmail.com"

{
"email": "johnsmith@gmail.com",
"autocorrect": "",
"deliverability": "DELIVERABLE",
"quality_score": 0.90,
"is_valid_format": {
"value": true,
"text": "TRUE"
},
"is_free_email": {
"value": true,
"text": "TRUE"
},
"is_disposable_email": {
"value": false,
"text": "FALSE"
},
"is_role_email": {
"value": false,
"text": "FALSE"
},
"is_catchall_email": {
"value": false,
"text": "FALSE"
},
"is_mx_found": {
"value": true,
"text": "TRUE"
},
"is_smtp_valid": {
"value": true,
"text": "TRUE"
},
"quality_score": 0.90,
}

The Domain Name System, commonly known as DNS, is mainly used to match a domain name with an IP address. This is how most Internet users can easily access their favorite websites. But DNS records are not simply limited to websites' IP resolution. They actually provide a whole configuration about a domain name. Among these configurations are MX records, which is an abbreviation of mail exchange. MX records are used to indicate to which mail server to connect to reach the mailboxes hosted on a domain. So an SMTP server needing to send an email will first examine the MX fields of the destination domain to find out which mail server to address next.

Frequently Asked Questions

What is an MX check and why does it matter for email validation?

An MX check looks up the DNS MX (Mail Exchange) records for an email address's domain to confirm that the domain is configured to receive mail. If no MX records exist, any email sent to that domain will bounce. Running this check before sending lets you remove undeliverable addresses before they damage your sender reputation.

What does an SMTP check actually verify?

An SMTP check connects to the domain's mail server on a standard port (25, 465, 587, or 2525) and performs a handshake to confirm the server is live and responding. It is the closest you can get to confirming deliverability without actually sending a message. A failed SMTP check means the mail server is unreachable or rejecting connections.

How do I look up MX records manually?

You can query MX records using the dig command on Unix/Linux (e.g., dig MX example.com) or by entering the domain at Google's DNS lookup service at dns.google.com. The result lists the mail server hostnames responsible for the domain, along with their priority values. If the lookup returns nothing, the domain has no MX records and cannot receive email.

Why can't I just use the SMTP VRFY command to check if a mailbox exists?

The VRFY command was designed to let senders verify individual mailboxes on a mail server, but nearly all modern SMTP servers disable or ignore it to prevent address harvesting by spammers. Because VRFY is unreliable in practice, email validation services instead perform a full SMTP handshake up to the RCPT TO step to infer whether a mailbox accepts mail.

What is a catch-all email server and how does it affect validation results?

A catch-all server accepts any message sent to the domain regardless of whether the specific mailbox exists. This means an SMTP check will return a positive result even for made-up addresses like xyz123@example.com. To detect catch-all behavior, a validation service sends a second probe with a randomly generated address and flags the domain as catch-all if that also succeeds. Abstract's Email Validation API surfaces this in its response so you can decide how to handle those addresses.

When should I use an API instead of running MX and SMTP checks myself?

Manual checks with dig or telnet work fine for one-off debugging but are not practical at scale. An API like Abstract's Email Validation API handles DNS lookups, SMTP handshakes, catch-all detection, and disposable-domain filtering in a single call, returning a structured JSON response. This is the right approach when validating addresses in a signup form, cleaning a bulk list, or running checks programmatically in your backend.

Emma Jagger
Emma Jagger

Emma Jagger is an experienced engineer and Google alumna with a degree from Carnegie Mellon University. She specializes in email validation, IP geolocation, and API integration, focusing on creating practical and scalable solutions through her technical writing.

Get your free
Email Validation
key now
See why the best developers build on Abstract
get started for free

Related Articles

Get your free
Email Validation
key now
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required