Skip to content

kehers/mailgun-validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

mailgun-validate

Simple email validation for node.js using Mailgun's API. Performs

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

You will need to sign up at mailgun.net for a public API key.

A PHP version is also available here: github.com/kehers/MG_Email.

Installation

npm install mailgun-validate

Use

var Validator = require('mailgun-validate');

var validator = new Validator('mail-gun-pub-key');
validator.validate('[email protected]', function(err, response) {
	if (err) {
		// Validation error
		// Log and fallback to regular expressions
		return;
	}

	/* response = {
	        "is_valid": true,
	        "address": "[email protected]",
	        "parts": {
	            "display_name": null,
	            "local_part": "foo",
	            "domain": "mailgun.net",
	        },
	        "did_you_mean": null
		}//*/

	if (response.is_valid) {
		// Email valid
	}
	else {
		// Email invalid
		if (response.did_you_mean) {
			// Did your mean response.did_you_mean?
		}
	}
})

Licence

MIT

About

Email validation for node.js using Mailgun's API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published