Using Mailgun API to validate email address
← Examples
Mailgun is one of most popular email services. It also provides free API to validate an email address based on:
- Syntax checks
- DNS validation
- Spell checks
- Email Service Provider (ESP)
The following example shows how to use the emailAddress validator to validate email address in the client side first. And then use the remote validator to connect with Mailgun validation API.
To use it, you need to sign up for a Mailgun account and get a free API key.
The crossDomain, dataType, validKey options of the remote validator used in the example are only available from v0.6.1
Email address | Description | Result |
---|---|---|
john@gmail.com | Does not meet Gmail minimum local-part length of 6 characters | |
john.smith@gmaill.com | Invalid, because gmaill.com does not have valid MX records | |
john@microsoft.io | Invalid because while microsoft.io does not have any MX records, it does have fallback A records, but alas no Mail Exchanger responds | |
john.smith@gmail.com | Meets Gmail 6 character minimum and all other requirements | |
"hello world"@domain.com | Meets pure syntax checks | |
hello@gail.com | Suggest new email address |