mailgun-validator

Validate email address using Mailgun's APIs

npm install mailgun-validator
4 downloads in the last month

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'
     ]
   }
npm loves you