Email Validation API PHP in Code

Stumped on verification? Try this email validation API PHP code and script function to verify emails in real-time on your website forms and applications.

PHP, or Personal Home Page, has been a widely accepted form of web application development since it was created by Rasmus Lerdorf in the early 90’s. Because of this growth PHP now stands for Hypertext Preprocessor to modern developers.

Since this mod happened the adoption rate has soared all the way to the use of email validation in a form. The functions surrounding a code or script to run verification on the server side are limited.

True email verification can not happen through PHP only. At this point is where a email validation API PHP script comes in to play. Without an API – the validation process is limited.

Processing emails through an API is best suited for dynamic and rapidly changing environments online. Examples of this include contact forms, registration or signup splash screens, and mobile apps.

There are only 3 steps involved to setting up a email validation API on your application. Requesting a trial key, integrating the code script in your function, and going live after testing completely.

Once you have your trial key and API string ready, use a PHP script to model the integration in your code.

Did that last part stump you? Don’t worry we have put a snippet example below to help you.

Stay calm, here is your email validation API PHP code broken down.

Function for Email Validation API PHP Code and Script


    // URL which should be requested

    $url = '';

    $apikey = 'YOUR API KEY';  // API Key

    $email  = 'Email Address to Test';  // Email to test

    // jSON String for request

    $url .= "?email=$email&key=$apikey";

    // Initializing curl

    $ch = curl_init( $url );

    if($ch == false) {

        die ("Curl failed!");

    } else {

        // Configuring curl options

        $options = array(

            CURLOPT_RETURNTRANSFER => true,            

            CURLOPT_HTTPHEADER => array('Content-type: application/json')


        // Setting curl options

        curl_setopt_array( $ch, $options );

        // Getting results

        $result =  curl_exec($ch); // Getting jSON result string

        // display JSON data

        echo "$result";                        


This function will speed up the small challenge you have been tasked with in creating a process to verify a email address submitted to your application. Model it to fit your requirements using these UML resources.

What you will notice as going through the script is how the email validation API PHP code pulls the verification process across the verification server with a key.