Email addresses are a universal mode of communication, and for many companies, their primary source of customer contact. However, when you rely on email addresses that are manually input by users, the potential for syntactical errors is significant. Utilizing the following API, you can check an email address for syntactical correctness while also identifying and contacting the email server to validate the existence of the account — all without sending any emails!
The first step is to install the SDK:
pip install cloudmersive-validate-api-client
After the installation, you can call the full validation function with the following code:
from __future__ import print_function
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_validate_api_client.EmailApi(cloudmersive_validate_api_client.ApiClient(configuration))
email = 'email_example' # str | Email address to validate, e.g. \"firstname.lastname@example.org\". The input is a string so be sure to enclose it in double-quotes.try:
# Fully validate an email address
api_response = api_instance.email_full_validation(email)
except ApiException as e:
print("Exception when calling EmailApi->email_full_validation: %s\n" % e)
This will return a response informing you of the validity of the input email address; if the address is invalid, it will show in the syntax, domain, and/or SMTP fields as ‘false’. If you prefer to only check the syntax of an email address, we have an API for that as well. Visit the Cloudmersive website to retrieve your free API key and gain access to 800 monthly calls across our library of APIs.