Skip to main content

Email verification module for Python using MailboxValidator API. It validates if the email is valid, from a free provider, contains high-risk keywords, whether it's a catch-all address and so much more.

Project description

MailboxValidator Python Module

This Python module enables user to easily validate if an email address is valid, a type of disposable email or free email.

This module can be useful in many types of projects, for example

  • to validate an user's email during sign up
  • to clean your mailing list prior to email sending
  • to perform fraud check
  • and so on

Installation

To install this module type the following:

pip install MailboxValidator

Dependencies

An API key is required for this module to function.

Go to https://www.mailboxvalidator.com/plans#api to sign up for FREE API plan and you'll be given an API key.

Functions

EmailValidation(api_key)

Creates a new instance of the MailboxValidator object with the API key.

validate_email(email_address)

Performs email validation on the supplied email address.

Return Fields

Field Name Description
email_address The input email address.
domain The domain of the email address.
is_free Whether the email address is from a free email provider like Gmail or Hotmail. Return values: True, False
is_syntax Whether the email address is syntactically correct. Return values: True, False
is_domain Whether the email address has a valid MX record in its DNS entries. Return values: True, False, -   (- means not applicable)
is_smtp Whether the mail servers specified in the MX records are responding to connections. Return values: True, False, -   (- means not applicable)
is_verified Whether the mail server confirms that the email address actually exist. Return values: True, False, -   (- means not applicable)
is_server_down Whether the mail server is currently down or unresponsive. Return values: True, False, -   (- means not applicable)
is_greylisted Whether the mail server employs greylisting where an email has to be sent a second time at a later time. Return values: True, False, -   (- means not applicable)
is_disposable Whether the email address is a temporary one from a disposable email provider. Return values: True, False, -   (- means not applicable)
is_suppressed Whether the email address is in our blacklist. Return values: True, False, -   (- means not applicable)
is_role Whether the email address is a role-based email address like admin@example.net or webmaster@example.net. Return values: True, False, -   (- means not applicable)
is_high_risk Whether the email address contains high risk keywords. Return values: True, False, -   (- means not applicable)
is_catchall Whether the email address is a catch-all address. Return values: True, False, Unknown, -   (- means not applicable)
mailboxvalidator_score Email address reputation score. Score > 0.70 means good; score > 0.40 means fair; score <= 0.40 means poor.
time_taken The time taken to get the results in seconds.
status Whether our system think the email address is valid based on all the previous fields. Return values: True, False
credits_available The number of credits left to perform validations.
error_code The error code if there is any error. See error table in the below section.
error_message The error message if there is any error. See error table in the below section.

is_disposable_email(email_address)

Check if the supplied email address is from a disposable email provider.

Return Fields

Field Name Description
email_address The input email address.
is_disposable Whether the email address is a temporary one from a disposable email provider. Return values: True, False
credits_available The number of credits left to perform validations.
error_code The error code if there is any error. See error table in the below section.
error_message The error message if there is any error. See error table in the below section.

is_free_email(email_address)

Check if the supplied email address is from a free email provider.

Return Fields

Field Name Description
email_address The input email address.
is_free Whether the email address is from a free email provider like Gmail or Hotmail. Return values: True, False
credits_available The number of credits left to perform validations.
error_code The error code if there is any error. See error table in the below section.
error_message The error message if there is any error. See error table below.

Sample Codes

Validate email

import MailboxValidator

mbv = MailboxValidator.EmailValidation('PASTE_API_KEY_HERE')
results = mbv.validate_email('example@example.com')

if results is None:
    print("Error connecting to API.\n")
elif 'error' not in results:
    print('email_address = ' + results['email_address'] + "\n")
    print('domain = ' + results['domain'] + "\n")
    print('is_free = ' + str(results['is_free']) + "\n")
    print('is_syntax = ' + str(results['is_syntax']) + "\n")
    print('is_domain = ' + str(results['is_domain']) + "\n")
    print('is_smtp = ' + str(results['is_smtp']) + "\n")
    print('is_verified = ' + str(results['is_verified']) + "\n")
    print('is_server_down = ' + str(results['is_server_down']) + "\n")
    print('is_greylisted = ' + str(results['is_greylisted']) + "\n")
    print('is_disposable = ' + str(results['is_disposable']) + "\n")
    print('is_suppressed = ' + str(results['is_suppressed']) + "\n")
    print('is_role = ' + str(results['is_role']) + "\n")
    print('is_high_risk = ' + str(results['is_high_risk']) + "\n")
    print('is_catchall = ' + str(results['is_catchall']) + "\n")
    print('mailboxvalidator_score = ' + str(results['mailboxvalidator_score']) + "\n")
    print('time_taken = ' + str(results['time_taken']) + "\n")
    print('status = ' + str(results['status']) + "\n")
    print('credits_available = ' + str(results['credits_available']) + "\n")
else:
    print('error_code = ' + str(results['error']['error_code']) + "\n")
    print('error_message = ' + results['error']['error_message'] + "\n")

Check if an email is from a disposable email provider

import MailboxValidator

mbv = MailboxValidator.EmailValidation('PASTE_API_KEY_HERE')
results = mbv.is_disposable_email('example@example.com')

if results is None:
    print("Error connecting to API.\n")
elif 'error' not in results:
    print('email_address = ' + results['email_address'] + "\n")
    print('is_disposable = ' + str(results['is_disposable']) + "\n")
    print('credits_available = ' + str(results['credits_available']) + "\n")
else:
    print('error_code = ' + results['error']['error_code'] + "\n")
    print('error_message = ' + results['error']['error_message'] + "\n")

Check if an email is from a free email provider

import MailboxValidator

mbv = MailboxValidator.EmailValidation('PASTE_API_KEY_HERE')
results = mbv.is_free_email('example@example.com')

if results is None:
    print("Error connecting to API.\n")
elif 'error' not in results:
    print('email_address = ' + results['email_address'] + "\n")
    print('is_free = ' + str(results['is_free']) + "\n")
    print('credits_available = ' + str(results['credits_available']) + "\n")
else:
    print('error_code = ' + results['error']['error_code'] + "\n")
    print('error_message = ' + results['error']['error_message'] + "\n")

Errors

error_code error_message
100 Missing parameter.
101 API key not found.
102 API key disabled.
103 API key expired.
104 Insufficient credits.
105 Unknown error.

Copyright

Copyright (C) 2018-2023 by MailboxValidator.com, support@mailboxvalidator.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MailboxValidator-1.3.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

MailboxValidator-1.3.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file MailboxValidator-1.3.0.tar.gz.

File metadata

  • Download URL: MailboxValidator-1.3.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for MailboxValidator-1.3.0.tar.gz
Algorithm Hash digest
SHA256 4ff6fca45e38dcfc51d8ff33f116c19a496664cf543e9eeb32592bac9d408f3c
MD5 bb36f6f6b88ba8f5641be61849b1a1c7
BLAKE2b-256 29942ec26bc6c402db8f7ebb022fa79fabf8b0e7fbb46609c2ff8a131eacd8bc

See more details on using hashes here.

File details

Details for the file MailboxValidator-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for MailboxValidator-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6d7ebcf923d35d9fb23a820b1e0beb2d1f8264eaf49fc4e279a83f9f7824078
MD5 145a2ffdb98b8715cfa0f0351169fd09
BLAKE2b-256 c032b377306d2da863986e53fe442380c322131b1d7f38bf7a1c762d97c35662

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page