Thursday, 8 February, 2018 UTC


Summary

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
  • mailboxlayer allows you to sign up for free
  • mailboxlayer provides email format validation
  • mailboxlayer provides extra logic to tell you if the email address is on a domain that’s disposable or if the email is a catchall
  • mailboxlayer is trusted by Zillow and Intel
  • mailboxlayer is from the same service provider for currencylayer, eversign, and streetlayer
  • Like other apilayer APIs, the mailboxlayer API is incredibly easy to use
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
    &[email protected]
    &smtp=1
    &format=1
This call presents a wealth of information:
{
  "email":"[email protected]",
  "did_you_mean":"",
  "user":"SOME_USER",
  "domain":"davidwalsh.name",
  "format_valid":true,
  "mx_found":true,
  "smtp_check":true,
  "catch_all":null,
  "role":false,
  "disposable":false,
  "free":false,
  "score":0.96
}
Let’s look at a few important pieces of information in the response:
  • mx_found – Many “parked” (aka not used) domains don’t set MX records, the records which provide email routing.  If no MX record is found for a domain, there’s a good chance the email address isn’t reliable.
  • format_valid – Many text formats have easy regular expressions for validation but email address validation is crazy — there are hundreds of regular expressions out there and many of them miss edge cases for valid email format.
  • disposable – Disposable email addresses are popular for users but can wreak havok on your email lists.  Knowing which services are disposable can save you a lot of email bounces and hassle.
  • score – mailboxlayer provides an aggregated score of the email address based on valid format, disposable status, an MX found, and other obvious factors.
  • did_you_mean – This is a helpful feature — you may be able to detect misspelled domains.
The information provided back from mailboxlayer is invaluable.
Privacy
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 = [email protected]
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!
The post Enhanced Email Validation with mailboxlayer (Sponsored) appeared first on David Walsh Blog.