David Walsh Blog

Enhanced Email Validation with mailboxlayer

Validation is an important part of managing any data you receive, especially when it comes to web forms.  If you really want to be secure with the data, you use HTML5 validation rules, JavaScript validation, and then the most importantly layer, the server-side layer.  Even then, you’re only validating text patterns.

What’s one of the most valuable data formats?  Email addresses.  So much of advertising these days is done by email and email services require a level of quality in email lists.  That means you need to perform every type of validation possible.  mailboxlayer allows you to easy validation various aspects of an email address in one simple call.  Let’s check it out!

Quick Hits

Using mailboxlayer

As with apilayer’s other services, mailboxlayer is easy to use.  Make a single call providing an access code and an email address to get important information about the email address:

curl https://apilayer.net/api/check?access_key=MY_KEY

This call presents a wealth of information:


Let’s look at a few important pieces of information in the response:

The information provided back from mailboxlayer is invaluable.


If you’re hesitant to use a third party service to check email addresses due to privacy or other concerns, simply swap out the username of the email address:

// email = REAL_USER@davidwalsh.name
var addressSplit = email.split('@');
addressSplit[0] = 'MASKED_USER';
var maskedAddress = addressSplit.join('');

// Now make the request

By swapping out the handle, you aren’t directly exposing the true email address but still get information about the domain.

Just like currencylayer and eversign, mailboxlayer is so easy to use.  No complicated API calls or parameters — just one simple call to get all the information you need.  These guys are really hitting the mark with API design and usability!