API Wrappers
You can find the Official ZeroBounce Java API v2 Wrapper:
Official JAVA SDK:
This is a java wrapper class example for the ZeroBounce API v2.
The project has 2 dependencies:
- Apache HttpClient
- JSON (org.json)
Either download the dependencies separately and add them to the relevant path or add the following dependencies to your pom.xml file if you're building via Maven (already added if you're cloning this repo):
Validate(email) method:
- PropertiesPossible Values
- getEmailAddress()The email address you are validating.
- getStatus()ValidInvalidCatch-AllUnknownSpamtrapAbuseDoNotMail
- getSubStatus()antispam_systemgreylistedmail_server_temporary_errorforcible_disconnectmail_server_did_not_respondtimeout_exceededfailed_smtp_connectionmailbox_quota_exceededexception_occurredpossible_trapsrole_basedglobal_suppressionmailbox_not_foundno_dns_entriesfailed_syntax_checkpossible_typounroutable_ip_addressleading_period_removeddoes_not_accept_mailalias_addressrole_based_catch_all
- getAccount()The portion of the email address before the "@" symbol.
- getDomain()The portion of the email address after the "@" symbol.
- getDidYouMean()Suggestive Fix for an email typo or [null]
- getDomainAgeDays()Age of the email domain in days or [null].
- isFreeEmail()[true/false] If the email comes from a free provider.
- isMXFound()[true/false] Does the domain have an MX record.
- getMXRecord()The preferred MX record of the domain or [null].
- getSMTPProvider()The SMTP Provider of the email or [null] (BETA).
- getFirstName()The first name of the owner of the email when available or [null].
- getLastName()The last name of the owner of the email when available or [null].
- getGender()The gender of the owner of the email when available or [null].
- getCountry()The country the IP address is from.
- getCity()The city the IP address is from.
- getZipcode()The zip code the IP address is from.
- getRegion()The region/state the IP address is from.
- getProcessedAt()The UTC time the email was validated.
getCredit() method
- PropertiesPossible Values
- getCredits()The number of credits left in account for email validation
//Depending on how you use the API, you might want it to time out faster,
//for example on a registration screen.
//Normally the API will return results very fast, but a small percentage of
//mail servers take upwards of 20+ seconds to respond.
//If the API times out, it will return a status of "Unknown" and
//a sub_status of "timeout_exceeded"
ZeroBounceApi zeroBounceApi = new ZeroBounceApi("YOUR_API_KEY",TIMEOUT_IN_SECONDS);
// Get credits and assign to int variable
int credits = zeroBounceApi.getCredits();
// validate email and assign result to a ZeroBounceResponse object
ZeroBounceResponse validation = zeroBounceApi.validate("some@email.com", "some.ip.address can be blank");
validation.getEmailAddress();
validation.getStatus();
validation.isDisposable();
validation.getCountry();
You can find the ZeroBounce JavaScript API v2 below:
The validate and getCredits methods return objects from which you can easily retrieve properties the properties below.
Properties and possible values returned by the methods:
validate method
- PropertyPossible Values
- addressThe email address you are validating.
- statusvalidinvalidcatch-allunknownspamtrapabusedo_not_mail
- sub_statusantispam_systemgreylistedmail_server_temporary_errorforcible_disconnectmail_server_did_not_respondtimeout_exceededfailed_smtp_connectionmailbox_quota_exceededexception_occurredpossible_trapsrole_basedglobal_suppressionmailbox_not_foundno_dns_entriesfailed_syntax_checkpossible_typounroutable_ip_addressleading_period_removeddoes_not_accept_mailalias_addresstoxicdisposablerole_based_catch_all
- accountThe portion of the email address before the "@" symbol.
- domainThe portion of the email address after the "@" symbol.
- did_you_meanSuggestive fix for an email typo or [null]
- domain_age_daysAge of the email domain in days or [null]
- free_email[true/false] If the email comes from a free provider
- mx_found[true/false] Does the domain have an MX record
- mx_recordThe preferred MX record of the domain or [null]
- smtp_providerThe SMTP Provider of the email or [null] (BETA)
- lastnameThe last name of the owner of the email when available or [null]
- genderThe gender of the owner of the email when available or [null]
- countryThe country the IP address is from
- regionThe state/region the IP address is from
- cityThe city the IP address is from
- zipcodeThe Zip Code the IP address is from
- processed_atThe UTC time the email was validated
GetCredit method
- PropertyPossible Values
- creditsThe number of credits left in account for email validation.
var ZeroBounceApi = new ZeroBounceApi(apiKey)
ZeroBounceApi.apiKey
ZeroBounceApi.getCredits()
ZeroBounceApi.validate("some@email.com", "some.ip.address can be blank")
You can find the Official ZeroBounce Python API v2 wrapper below:
You can find the ZeroBounce Python SDK below:
Example usage
The validate and get_credit methods return objects from which you can easily retrieve properties the properties below.
Properties and possible values returned by the methods:
validate method
- PropertyPossible Values
- addressThe email address you are validating.
- statusvalidinvalidcatch-allunknownspamtrapabusedo_not_mail
- sub_statusantispam_systemgreylistedmail_server_temporary_errorforcible_disconnectmail_server_did_not_respondtimeout_exceededfailed_smtp_connectionmailbox_quota_exceededexception_occurredpossible_trapsrole_basedglobal_suppressionmailbox_not_foundno_dns_entriesfailed_syntax_checkpossible_typounroutable_ip_addressleading_period_removeddoes_not_accept_mailalias_addresstoxicdisposablerole_based_catch_all
- accountThe portion of the email address before the "@" symbol.
- domainThe portion of the email address after the "@" symbol.
- did_you_meanSuggestive fix for an email typo or [null]
- domain_age_daysAge of the email domain in days or [null]
- free_email[true/false] If the email comes from a free provider
- mx_found[true/false] Does the domain have an MX record
- mx_recordThe preferred MX record of the domain or [null]
- smtp_providerThe SMTP Provider of the email or [null] (BETA)
- lastnameThe last name of the owner of the email when available or [null]
- genderThe gender of the owner of the email when available or [null]
- countryThe country the IP address is from
- regionThe state/region the IP address is from
- cityThe city the IP address is from
- zipcodeThe Zip Code the IP address is from
- processed_atThe UTC time the email was validated
GetCredit method
- PropertyPossible Values
- creditsThe number of credits left in account for email validation.
from zerobounce import ZeroBounceAPI
zba = ZeroBounceAPI('yourapikey____________')
print zba.get_credits()
resp1 = zba.validate('flowerjill@aol.com','123.145.124.12')
print resp1
{
"address":"flowerjill@aol.com",
"status":"valid",
"sub_status":"",
"free_email":True,
"did_you_mean":None,
"account":"flowerjill",
"domain":"aol.com",
"domain_age_days": "8426",
"smtp_provider":"yahoo",
"mx_record":"mx-aol.mail.gm0.yahoodns.net",
"mx_found": "true",
"firstname":"Jill",
"lastname":"Stein",
"gender":"female",
"country":"United States",
"region":"Florida",
"city":"West Palm Beach",
"zipcode":"33401",
"processed_at":"2017-04-01 02:48:02.592"
}
print resp.firstname
Jill
print resp2.status
valid
Official ZeroBounce API v2 Wrapper:
Official PHP SDK:User Contributed Libraries:This is a PHP wrapper class example for the ZeroBounce API.
Example usage:
The validation methods return objects on which you call get methods which return the relevant information. Please see the sample code on the right:
The validate and getCredits methods return objects from which you can easily retrieve properties the properties below.
Properties and possible values returned by the methods:
validate method
- PropertyPossible Values
- addressThe email address you are validating.
- statusvalidinvalidcatch-allunknownspamtrapabusedo_not_mail
- sub_statusantispam_systemgreylistedmail_server_temporary_errorforcible_disconnectmail_server_did_not_respondtimeout_exceededfailed_smtp_connectionmailbox_quota_exceededexception_occurredpossible_trapsrole_basedglobal_suppressionmailbox_not_foundno_dns_entriesfailed_syntax_checkpossible_typounroutable_ip_addressleading_period_removeddoes_not_accept_mailalias_addresstoxicdisposablerole_based_catch_all
- accountThe portion of the email address before the "@" symbol.
- domainThe portion of the email address after the "@" symbol.
- did_you_meanSuggestive fix for an email typo or [null]
- domain_age_daysAge of the email domain in days or [null]
- free_email[true/false] If the email comes from a free provider
- mx_found[true/false] Does the domain have an MX record
- mx_recordThe preferred MX record of the domain or [null]
- smtp_providerThe SMTP Provider of the email or [null] (BETA)
- lastnameThe last name of the owner of the email when available or [null]
- genderThe gender of the owner of the email when available or [null]
- countryThe country the IP address is from
- regionThe state/region the IP address is from
- cityThe city the IP address is from
- zipcodeThe Zip Code the IP address is from
- processed_atThe UTC time the email was validated
GetCredit method
- PropertyPossible Values
- creditsThe number of credits left in account for email validation.
<?php
require_once("zerobounce.php");
$zba = new ZeroBounceAPI('YOUR_API_KEY');
//print the credit balance
print_r($zba->get_credits());
//instantiate a validation object following a call to
//validate and print individual elements
$validation = $zba->validate('email@address.com', 'IP can be blank');
echo $validation['address'];
echo $validation['status'];
print_r($zba->validate('email@address.com', 'IP'));
?>
You can find this User Contributed PHP7 wrapper below:
Prerequisites You need an active account at https://zerobounce.net to use this library. From there, grab your API Key under API - Keys & Info.
Installation To include this in your project, install it using Composer.
As we use return types and type hints, this library requires PHP 7.1.
composer require nickdnk/zerobounce-php
Tests Enter your API key into the ZeroBounceTest file and run it. This uses the test-emails supplied by ZeroBounce and will not cost you credit.
use nickdnkZeroBounceEmail;
use nickdnkZeroBounceResult;
use nickdnkZeroBounceZeroBounce;
// You can modify the timeout using the second parameter. Default is 15.
$handler = new ZeroBounce('my_api_key', 30);
$email = new Email(
// The email address you want to check
'some-email@domain.com',
// and if you have it, the IP address - otherwise null or omitted
'123.123.123.123'
);
try {
// Validate the email
$result = $handler->validateEmail($email);
if ($result->getStatus() === Result::STATUS_VALID) {
// All good
if ($result->isFreeEmail()) {
// Email address is free, such as @gmail.com, @hotmail.com.
}
/**
* The user object contains metadata about the email address
* supplied by ZeroBounce. All of these may be null or empty
* strings, so remember to check for that.
*/
$user = $result->getUser();
$user->getCountry();
$user->getRegion();
$user->getZipCode();
$user->getCity();
$user->getGender();
$user->getFirstName();
$user->getLastName();
} else if ($result->getStatus() === Result::STATUS_DO_NOT_MAIL) {
// The substatus code will help you determine the exact issue:
switch ($result->getSubStatus()) {
case Result::SUBSTATUS_DISPOSABLE:
case Result::SUBSTATUS_TOXIC:
// Toxic or disposable.
break;
case Result::SUBSTATUS_ROLE_BASED:
// admin@, helpdesk@, info@ etc; not a personal email
break;
// ... and so on.
}
} else if ($result->getStatus() === Result::STATUS_INVALID) {
// Invalid email.
} else if ($result->getStatus() === Result::STATUS_SPAMTRAP) {
// Spam-trap.
} else if ($result->getStatus() === Result::STATUS_ABUSE) {
// Abuse.
} else if ($result->getStatus() === Result::STATUS_CATCH_ALL) {
// Address is catch-all; not necessarily a private email.
} else if ($result->getStatus() === Result::STATUS_UNKNOWN) {
// Unknown email status.
}
/*
* To find out how to use and react to different status and
* substatus codes, see the ZeroBounce documentation at:
* https://www.zerobounce.net/docs/?swift#version-2__v2__
*/
} catch (
ickdnkZeroBounceAPIError $exception) {
// Something happened. Perhaps a bad API key or insufficient credit.
}
User Contributed Ruby Wrapper(s):
User Contributed Delphi Wrapper(s):
User Contributed NodeJS Wrapper(s):
You can find our C# SDK, example usage, and documentation on our official GitHub page below:
You can find our IOS SDK, example usage, and documentation on our official GitHub page below:
You can find our Android SDK, example usage, and documentation on our official GitHub page below:
User Contributed GoLang Wrapper