I received lot of requests from my readers regarding how to check email address exists or not in PHP. It help us to avoid invalid emails added into their database. In this tutorial, we can easily Verify and Validate Email Address in Real Time or not valid using Kickbox API
Kickbox makes it easy to verify your email lists, or integrate email verification into your application with their API. Kickbox verifies email addresses using the Simple Mail Transfer Protocol (SMTP).
check out my popuplar article on How to Check Internet Connection Exists or Not using Javascript?
Contents
Step 1: Create a Free Kickbox Account
Getting started with Kickbox is free. Your account comes with 100 free verifications. Click here to sign up.
After registration and login into Kickbox, you can see 100 free verifications added into your account
Step 2: Verifying Email Addresses With Kickbox API
Kickbox’s API can be integrated into your web applications to verify email addresses in real-time.
You need to Create a Verification App to generate an API key. I created the app with the name called “w3lessons”
After created the APP, you can see the API with usage statistics overall. Please get the API from this dashboard
Step 3 : API usage in PHP Curl to Verify Email Address in Real Time
API EndPoint
https://api.kickbox.io/v2/verify?email=bill.lumbergh@gamil.com&apikey=your-api-key
PHP code to validate email address using CURL. below code will convert json into php object
function get_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$res=curl_exec($ch);
curl_close($ch);
$result=json_decode($res,true);
return $result;
}
$apikey = "your api key";
$email = "bill.lumbergh@gamil.com";
$url = 'https://api.kickbox.io/v2/verify?email='.$email.'&apikey='.$apikey;
$response = get_curl($url);
print_r($response);
Response after executing kickbox API using PHP CURL
{
"result":"undeliverable",
"reason":"rejected_email",
"role":false,
"free":false,
"disposable":false,
"accept_all":false,
"did_you_mean":"bill.lumbergh@gmail.com",
"sendex":0,
"email":"bill.lumbergh@gamil.com",
"user":"bill.lumbergh",
"domain":"gamil.com",
"success":true,
"message":null
}
If the result field is undeliverable then the email address is invalid
A successful API call responds with the following values:
- result
string
– The verification result:deliverable
,undeliverable
,risky
,unknown
- reason
string
– The reason for the result. Possible reasons are:invalid_email
– Specified email is not a valid email address syntaxinvalid_domain
– Domain for email does not existrejected_email
– Email address was rejected by the SMTP server, email address does not existaccepted_email
– Email address was accepted by the SMTP serverlow_quality
– Email address has quality issues that may make it a risky or low-value addresslow_deliverability
– Email address appears to be deliverable, but deliverability cannot be guaranteedno_connect
– Could not connect to SMTP servertimeout
– SMTP session timed outinvalid_smtp
– SMTP server returned an unexpected/invalid responseunavailable_smtp
– SMTP server was unavailable to process our requestunexpected_error
– An unexpected error has occurred
- role
true | false
– true if the email address is a role address (postmaster@example.com
,support@example.com
, etc) - free
true | false
– true if the email address uses a free email service like gmail.com or yahoo.com. - disposable
true | false
– true if the email address uses a disposable domain like trashmail.com or mailinator.com. - accept_all
true | false
– true if the email was accepted, but the domain appears to accept all emails addressed to that domain. - did_you_mean
null | string
– Returns a suggested email if a possible spelling error was detected. (bill.lumbergh@gamil.com
->bill.lumbergh@gmail.com
) - sendex
float
– A quality score of the provided email address ranging between 0 (no quality) and 1 (perfect quality). More information on the Sendex Score can be found here. - email
string
– Returns a normalized version of the provided email address. (BoB@example.com
->bob@example.com
) - user
string
– The user (a.k.a local part) of the provided email address. (bob@example.com
->bob
) - domain
string
– The domain of the provided email address. (bob@example.com
->example.com
) - success
true | false
– true if the API request was successful (i.e., no authentication or unexpected errors occurred)
The API is rate-limited to a maximum of 25 simultaneous connections per account. As you integrate the Kickbox API, ensure your application does not exceed this limit
Alternatively you can also use php library to verify email address – https://github.com/kickboxio/kickbox-php
View Live DemoYou can also checkout Top 10 Bulk Email Verification and Validation Services Compared
Awsome Man, I Found what i needed , you save my time. Thanks.
i dont understand can u share source share demo ?
Awesome Post karthikeyan 🙂 I’m going to use this feature in my next web application to avoid invalid emails
Thanks Gabriel 🙂