Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (29 sloc) 1.81 KB


Drop-in replacement for Django's forms.EmailField. Uses to validate email addresses against a number of factors. Caches results and fails silently should anything go wrong.

MailTest is a free email domain validation API. Reject email addresses from invalid domains (i.e. the domain is unregistered or has no MX records). Optionally reject disposable email addresses and monetized bounce services.


You can install django-mailtestfield with pip by typing:

pip install django-mailtestfield

Or with easy_install by typing:

easy_install django-mailtestfield

Or manually by downloading a tarball and typing:

python install


Simply import the form field and use it:

from django import forms
from mailtest.fields import EmailMailTestField

class MyForm(forms.Form):
    email = EmailMailTestField()


See the dummy subdomains on the MailTest website. E.g. to test for a disposable email address response, use the email address "".


django-mailtestfield has a few settings with sensible defaults:

MAILTEST_USE_HTTPS Boolean, default True: Connect to via HTTPS.
MAILTEST_REJECT_DISPOSABLE Boolean, default True: Reject disposable email addresses.
MAILTEST_REJECT_ROBOT Boolean, default True: Reject monetized bounce addresses.
MAILTEST_CACHE_AGE Integer, default 86400 (24 hours): Length of time to cache results.

The message strings can also be modifed in the settings.

MAILTEST_MSG_INVALID default "This email address is invalid"
MAILTEST_MSG_DISPOSABLE default "Disposable email addresses are not allowed"
MAILTEST_MSG_ROBOT default "This email address is blocked"

You can’t perform that action at this time.