2 mins

3 reasons why you should stop using regex email validation

From poor delivery and response rates to damaging your sender reputation, mistakes and bogus emails input by users can negatively impact your marketing campaigns. A quick internet search will find many services purporting to verify bad emails. But are they all delivering the same level of service?

For most developers looking for a quick solution, the first point of call is usually a regular expression, often shortened to regex. However, regex is complex to write and debug, and only does half the job.

Here are 3 more reasons why you should pull the plug on regex for validating your email addresses.

1) It’s too restrictive

More often than not regex is far too restrictive. Most of the regex examples available are incorrect and fail to cater for rarer email addresses for the user portion of an email address.

Does your verification account for the various characters and symbols people use in their email address? The RFC goes into the requirements of how email addresses need to be formatted, and there is a whole heap of variation. The local string (the part of the email address that comes before the @ permits a lot more characters than you might expect. !#$%&'*+-/=?^_`{| }~ are all valid characters, so if you’re excluding these, you could be turning potential customers away. It’s also worth bearing in mind that your users may choose to filter their inbox by appending a modifier onto their address for example ‘email+spam@gmail.com’.

2) Regex doesn’t actually check...

a) Whether the domain even exists.

b) If the domain does exist – does it have a mail server that is routable? (MX records that point the internet to the mail server for that domain).

c) If the user account actually exists. Although perhaps syntactically correct, an email that passes regex validation won’t be able to guarantee the existence of the user's inbox.

3)  It lets in temporary addresses

Even with all of the above checks it’s not an easy task to check if an email address is “valid” as there are lots of 10/15 minute mailbox providers. These companies will create a random domain, register a mail server on it and give you a temporary email address for 10 minutes before closing it down again. These temporary addresses will pass all validity checks but still aren’t what most business would deem a valid, marketable email address and certainly not something you want to be wasting your marketing resource on.

So what’s the solution?

A good email validation tool will go way beyond checking the syntax of the email address or pinging a mail server. Businesses need to invest in a solution that conducts additional, rigorous checks in order for accurate and valid responses to be returned. Simply checking that emails contain an @ symbol and dots is just not enough. A good tool will also check that the domain exists and that it is able to receive inbound messages, all in real-time.

Email verification from Loqate is available on a pay-as-you-go basis with no setup fees and no minimum usage limits. Our API makes it possible to integrate email address checks on your website, app or CRM forms – wherever you collect email addresses.