Guides
Last Updated Jun 08, 2023

What is the best way to verify an email?

Emma Jagger

Table of Contents:

Get your free
API
key now
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
Get your free
Email Verification API
key now
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

Whether it comes from a user, from a remote API, or even from your database, it is necessary to validate the data's consistency for any data type.

What is email validation?

Anyone who processes data understands the need to validate it upon user input. A basic validation ensures that the data is not empty and within the expected length, and verifies the format. This last point is only necessary for certain data categories, such as date and time, telephone numbers, and of course, email addresses.

To perform a more advanced validation, it is necessary to differentiate the terms validate and verify. For an email address, verifying is making sure that the email address exists and it corresponds to a mailbox hosted on a correctly configured server.

To understand the necessity of the verification, take a single example: the email address ljksghiqslduf@fdgsdfg.sfg will pass the validation in terms of length and format, but, likely, it will not pass the verification because no mailbox exists with this address.

How to verify an email address?

Let's take the example of an email address that would be provided by a person who wants to subscribe to your newsletter. Logically your script will check the following elements:

  • the value provided by the user is not empty,
  • its length does not exceed that authorized by the database, at the risk of being truncated,
  • it contains the symbol @.

These rules are sufficient for a first validation step, and are typically what an email validation regular expression (or regex) will do. Then, and since you want to make sure that the email address exists and belongs to the registering person, your script will send a message containing a confirmation link to the provided address. It is only when the person clicks on this link, which includes a secret identification key, that their subscription to your newsletter will be valid.

This system works very well, so much so that it is used by many websites, whether for newsletter subscription or account creation.

Let’s send your first free
API
Email Verification API
call
See why the best developers build on Abstract
Get your free api

The importance of verifying an email address and not just validating its format

A user who registers on your website and types a typo on his address will not understand why he does not receive a confirmation email and will abandon his registration thinking that your site is faulty.

Even worse, if you periodically send messages to mailing lists that contain email addresses that do not exist, they will bounce back, and your domain name will end up being considered a spam domain and receive penalties, which will ruin the deliverability of all your emails.

Therefore, verifying an email address is essential to improve the success rates of all things related to your users' email addresses and improve your business.

Is it necessary to check the email addresses once or regularly?

But what about historical data? After some time, users may delete their mailboxes, email services may get closed, and the emails in your database could become invalid.

You may consider that having invalid email addresses in your database is not an issue, but you will observe that the rate of invalid emails will increase over time. The direct consequence is that all your informational or promotional mailings will have a higher proportion of bouncebacks, and that's something you should be concerned about. Your emails may also have a very low open rate because they're being sent to free or disposable emails addresses.

How to validate and verify an email address

The validation of an email address must be limited to a minimum set of rules. According to the RCF 2822, the email box's name (before the @) can contain any characters, including spaces. On the other hand, concerning the domain name (after the @), it is enough to ensure a dot's presence.

Here is a regular expression that is sufficient to validate the format of an email address:


/.+  # One or more characters
 @   # The @ sign
 .+  # One or more characters
 \.  # The dot sign
 .+/ # One or more characters

In terms of verification, however, a much more complex system is required. The verification script must verify that the domain name exists. It must also query the DNS records and check that it contains MX fields, which indicate the domain's email servers' addresses. And from these addresses, check that the SMTP servers exist and are working. Implementing such a system by yourself could be a waste of your time, especially knowing there is an efficient and free web service that does all this.

How to painlessly validate and verify an email address.

Abstract provides a free email address validation API service.

The service is fast and can be queried using a simple GET request. Abstract checks the email address format, the domain configuration, and the presence of an SMTP server. It will also detect if the email address is provided by a disposable email service, which is a good thing to know before accepting a user account creation.

The documentation is clear and precise, and you will be ready to use the API in seconds.

Here is an example of a JSON response:


{
  "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,
}

What is email bounceback, and what does it mean for your business?

A bounceback email is simply an email message that cannot be delivered to the recipient. The most common reason for this kind of error is that the recipient's mailbox does not exist.

But bouncebacks have a significant impact on your business: more emails will be sent back to your servers, more the reputation of your domain names and IP addresses used by your servers will suffer. There are regulations on the Internet that combat email spam, and the bounceback rate is one of their metrics.

If you do nothing about bounceback, your mail servers could be flagged as spam servers, and they would be blacklisted from a vast number of mail servers, which would ruin your emails' deliverability.

How do you keep a database of email addresses always up to date?

You should regularly check all the email addresses in your database. It is however unthinkable to send a verification link once a month to your users, as you did at the registration time. It is necessary to do this verification by other means.

The smart solution is to regularly pass your email addresses through an email validation API to ensure that the SMTP configuration corresponding to the email address is still correct. Abstract provides a free API that can do just that and is very easy to use, although there are many email validation and verification API's. The Abstract API can be used by any language capable of making a GET request on the Internet. Here is an example that you can use directly in your browser: Abstract also includes other APIs, such as the company enrichment API.

https://emailvalidation.abstractapi.com/v1/?api_key=YOU_API_KEY&email=johnsmith@gmail.com

And here is the response:


{
  "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,
}

4.7/5 stars (7 votes)

Emma Jagger
Engineer, maker, Google alumna, CMU grad
Get your free
Email Verification API
API
key now
Abstract's Email Verification API makes it easy verify emails quickly.
get started for free

Related Articles

Get your free
API
Email Verification API
key now
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