Mailgun plugin

Validate an email address by using Mailgun API


Mailgun is one of most popular email services. It also provides free API to validate an email address based on:

  • Mailbox detection
  • Syntax checks (RFC defined grammar)
  • DNS validation
  • Spell checks
  • Email Service Provider (ESP) specific local-part grammar (if available)

To use it, you need to sign up for a Mailgun account and get a free API key.

The following piece of code is the starting point to use the Mailgun plugin:

The sample code above assumes that the FormValidation files are placed inside the vendors directory. You might need to change the path depending on where you place them on the server.


Option Type Description
apiKey * String The API key provided by Mailgun
field * String The field name that will be validated
message * String Error message indicates the input is not valid
suggestion Boolean Show suggestion if the email is not valid. By default, it is set to false

Basic example

You can use the following sample email addresses to test with your app.

Description Sample
Does not meet Gmail minimum local-part length of 6 characters
Invalid, because does not have valid MX records
Invalid because while does not have any MX records, it does have fallback A records, but alas no Mail Exchanger responds
Meets Gmail 6 character minimum and all other requirements
Meets pure syntax checks "hello world"
Suggest new email address

The following sample code demonstrates how to use Mailgun plugin to validate email address which its form is made with Tachyons:


  • v1.0.0: First release

Related validators

The following validators might be useful to you.