Guide to Verification of PHP Email Validation

Receiving emails through the website or web application is an important feature and often the only way that web development company can get in touch with their customers. If you look back, how often do you receive an email from a potential customer with an invalid or incorrect email address? Of course, you can use advanced regular expression patterns to verify the format of the email address, but these patterns do not verify if the email address exists. This tutorial is about double email address validation, first, we verify the email address format and then we validate the email addresses with an API system in PHP.

 

In what kind of situations should you verify an email address?

You need a valid email address all the time, but sometimes additional control is necessary to achieve your goals. However, web development company use a second layer of email address validation to:

  • Contact forms: Most contact forms include only the necessary form fields such as name, email address and message. There is no possibility to contact your new potential customer if the email address sent is incorrect.
  • Webshop orders: in this case, you get (often) much more information, but your customer will never get an order confirmation if the email address you entered during the payment process is invalid.
  • Mailing lists: If your mailing list was not used for some time, many of the included email addresses may expire in the meantime. The next email campaign may have a high bounce rate and this is often a problem for your email marketing provider. Verify all email addresses before sending a new campaign. Check the PHP bonus feature below!

 

Validate more with the Mailboxlayer API

Mailboxlayer is a service of API layer, a company based in Vienna, Austria. They offer not only the email validation API but also API systems for currency conversion, PDF creation and many more. All your API services are based on a premium model, so you can use them for free if you don’t make so many API calls.

A free Mailboxlayer API account includes 250 credits per month. This might be enough for smaller sites, but only if you send only those addresses with a “good” email address format. For example, a regular expression test before sending the email address to the API endpoint. 

 

What kind of validation methods does Mailboxlayer use?

In addition to verifying the format of the email address, Mailboxlayer is using different methods to verify your sent email address:

  • DNS validation: a valid MX record is required to send an email. If the MX record for the domain name used does not exist, no email message can be delivered.
  • SMTP Check: Mailboxlayer API will create an SMTP connection to verify that a simple HELO command is possible.
  • Capture all email addresses: a capture all address accepts all email addresses for the domain name used. If your email address verification is used for a mailing list, an address that captures all email addresses may have a low email opening rate.
  • General and disposable email addresses: Mailboxlayer can also recognize general email addresses such as support, information or contact@domain.com. Those email addresses and also disposable addresses such as user123@domain.com could work with a low email opening rate by sending an email campaign to your mailing list.
  • Valid syntax: As in your application, the API will first verify the syntax of your email address (to ensure validation time and resources).

 

Set up your PHP email validation (test) script

You can use the Mailboxlayer email validation API with any programming language that can analyze a JSON formatted data response.  You may have noticed that the email validation service has provided a suggestion for email addresses hosted by popular email service providers. If you enter “test@domain.com”, the response shows the suggestion “test@hotmail.com” as a possible valid email address. Play a little with the example to see what kind of response you get for different entries. Also, note the “score” value, a value greater than 0.8 is a good value for email marketing campaigns. If you use the email addresses collected only for transactional emails, a value greater than 0.65 is acceptable.

 

Bonus: PHP function to verify a list of email addresses

We suggest rechecking the email addresses of your mailing list if your last campaign was sent more than 6 months ago. Our web development company do the same for our clients’ lists also with a small PHP script. We use the Mailboxlayer API for this job. Follow these steps to clean your mailing list:

  • Export all of your email addresses from MailChimp or any other email marketing provider you use (you only need a column with the email address. You may need to edit the .csv file using a spreadsheet editor).
  • Rename your .csv file to match the name inside the script and also add your Mailboxlayer API key.
  • Run the PHP script using the PHP command line mode (CLI). The script will read its .csv file and verify each email address through the API system. The Mailboxlayer system response is added to the file called “emails-verified.csv”.
  • Download / open the file “emails-checked.csv” in your spreadsheet editor. Email addresses with a low score and/or missing results for MX and/or SMTP are candidates to be removed from your mailing list.

 

To comment on this article and to know more about the services of web development company please check Moz Web Development.

Source: Web Development Blog

Facebook
LinkedIn
Reddit
WhatsApp
Twitter
Pinterest
Tumblr