Skip to main content

Email verification module for Flask 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 Flask Python Module

This Flask Python module provides an easy way to call the MailboxValidator API which validates if an email address is a valid one.

This module can be used in many types of projects such as:

  • validating a user's email during sign up
  • cleaning your mailing list prior to an email marketing campaign
  • a form of fraud check

Installation

To install this module type the following:

pip install flask_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.

In order to use this module to validate email from form, WTForms and Flask-WTF need to be installed. Also, nose2 need to be installed in order to run the test file.

Usage for validate email from form

Note: WTForms and Flask-WTF must be installed before using this features.

This Flask Python module had three different validator for different uses: EmailValidation for validating email address by all parameters, DisposableEmailValidation for validating disposable email address, and FreeEmailValidation for validating free email address.

  1. Import the validator class from the package. For example: from flask_MailboxValidator.SingleValidation import EmailValidation
  2. Call the validator in validator array along with your API key. For example: email = TextField('Email:', validators=[validators.required(), EmailValidation(apikey='Your_API_Key')])

Usage for validating emails

import flask_MailboxValidator
from flask import Flask
from flask import jsonify

app = Flask(__name__)

mbv = flask_MailboxValidator.SingleValidation('PASTE_API_KEY_HERE')
results = mbv.ValidateEmail('example@example.com')

@app.route('/')
def display_result():
	if results is None:
		return("Error connecting to API.\n")
	elif results['error_code'] == '':
		return (jsonify(results))
	else:
		return('error_message = ' + results['error_message'] + "\n")

Functions

SingleValidation(api_key)

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

ValidateEmail(email_address)

Performs email validation on the supplied email address.

Result Fields

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 below.

error_message

The error message if there is any error. See error table below.

Usage for checking if an email is from a disposable email provider

import flask_MailboxValidator
from flask import Flask
from flask import jsonify

app = Flask(__name__)

mbv = flask_MailboxValidator.SingleValidation('PASTE_API_KEY_HERE')
results = mbv.DisposableEmail('example@example.com')

@app.route('/')
def display_result():
	if results is None:
		return("Error connecting to API.\n")
	elif results['error_code'] == '':
		return (jsonify(results))
	else:
		return('error_message = ' + results['error_message'] + "\n")

Functions

SingleValidation(api_key)

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

DisposableEmail(email_address)

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

Result Fields

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 below.

error_message

The error message if there is any error. See error table below.

Usage for checking if an email is from a free email provider

import flask_MailboxValidator
from flask import Flask
from flask import jsonify

app = Flask(__name__)

mbv = flask_MailboxValidator.SingleValidation('PASTE_API_KEY_HERE')
results = mbv.FreeEmail('example@example.com')

@app.route('/')
def display_result():
	if results is None:
		return("Error connecting to API.\n")
	elif results['error_code'] == '':
		return (jsonify(results))
	else:
		return('error_message = ' + results['error_message'] + "\n")

Functions

SingleValidation(api_key)

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

FreeEmail(email_address)

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

Result Fields

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 below.

error_message

The error message if there is any error. See error table below.

Test

To run the test file, you will first need to replace the 'PASTE_API_KEY_HERE' with your API key in the test file(Located at test directory). After that, run this command in terminal: python setup.py test

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 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

flask_MailboxValidator-1.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

flask_MailboxValidator-1.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file flask_MailboxValidator-1.1.0.tar.gz.

File metadata

  • Download URL: flask_MailboxValidator-1.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.12.5 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.0

File hashes

Hashes for flask_MailboxValidator-1.1.0.tar.gz
Algorithm Hash digest
SHA256 99df2b7c7c0d294d7a8240fe3c869a388aa4eb7cea4ff50741e2cb1d7c9666ab
MD5 87ce8e846b626241c19d185ca92b5c32
BLAKE2b-256 d3d0c73a487499cac8a109c10866bb2b87677e6280853c065d3691927862d2f2

See more details on using hashes here.

File details

Details for the file flask_MailboxValidator-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: flask_MailboxValidator-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.12.5 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.0

File hashes

Hashes for flask_MailboxValidator-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4fe14e0048367966a2bfa952e1f2ba3b2f701bdc9c5d0c208fb87c70b14e0216
MD5 07f44d1bb614a48756f6fd8aaf0f6826
BLAKE2b-256 1501aac885232d0a136c240328a2036108018c9c3fd6a9878b71e69b54693683

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