How to Validate an Email Address in Python

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!

Image for post
Image for post

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
import time
import cloudmersive_validate_api_client
from import ApiException
from pprint import pprint

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.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store