Skip to content
Node.js module to validate email address using Mailgun's API
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
.gitignore
LICENSE.md
README.md
package.json

README.md

mailgun-validator

Install

  npm install mailgun-validator

API

  var mgval = require('mailgun-validator')('<PUBLIC_APIKEY>')

Validator.validate(address:String, cb:Function)

Validates the given address

Examples:

  mgval.validate('john.smith@gmail.com', function(err, res) {
    if (err) {
      throw err
    } else {
      console.log(res)
    }
  })

Returns:

  { 
    is_valid: true, 
    parts: { 
      local_part: 'john.smith', 
      domain: 'gmail.com',
      display_name: ''
    },
    address: 'john.smith@gmail.com',
    did_you_mean: null
  }

Validator.parse(addresses:String|Array, syntaxOnly:Boolean, cb:Function)

Parses the given addresses

Example:

  mgval.parse(['john@gmail.com', 'hello@world.com'], function(err, res) {
    if (err) {
      throw err
    } else {
      console.log(res)
    }
  })

Returns:

   {
     parsed: [
       'john@gmail.com',
       'hello@world.com'
     ],
     unparseable: []
   }

Example:

  mgval.parse(['john@gmail.com', 'hello@world.com'], false, function(err, res) {
    if (err) {
      throw err
    } else {
      console.log(res)
    }
  })

Returns:

   {
     parsed: [
       'hello@world.com'
     ],
     unparseable: [
       'john@gmail.com'
     ]
   }
Something went wrong with that request. Please try again.