New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mailgun-js

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailgun-js - npm Package Compare versions

Comparing version 0.9.1 to 0.10.1

30

lib/mailgun.js

@@ -19,2 +19,3 @@ var tsscmp = require('tsscmp');

this.apiKey = options.apiKey;
this.publicApiKey = options.publicApiKey;
this.domain = options.domain;

@@ -67,2 +68,15 @@ this.auth = [this.username, this.apiKey].join(':');

Mailgun.prototype.getRequestOptions = function (resource) {
var o = this.options;
// use public API key if we have it for the routes that require it
if (resource.indexOf('/address') >= 0 && this.publicApiKey) {
var copy = Object.assign({}, this.options);
copy.auth = [this.username, this.publicApiKey].join(':');
o = copy;
}
return o;
};
Mailgun.prototype.request = function (method, resource, data, fn) {

@@ -139,2 +153,18 @@ var fullpath = resource;

Mailgun.prototype.validate = function (address, fn) {
var resource = `/address/validate`;
var options = this.getRequestOptions(resource);
var req = new Request(options);
return req.request('GET', resource, { address }, fn);
};
Mailgun.prototype.parse = function (addresses, fn) {
var resource = `/address/parse`;
var options = this.getRequestOptions(resource);
var req = new Request(options);
return req.request('GET', resource, { addresses }, fn);
};
builder.build(Mailgun, resources);

@@ -141,0 +171,0 @@

12

package.json

@@ -8,3 +8,3 @@ {

],
"version": "0.9.1",
"version": "0.10.1",
"homepage": "https://github.com/bojand/mailgun-js",

@@ -24,6 +24,6 @@ "license": "MIT",

"dependencies": {
"async": "~2.1.2",
"debug": "~2.2.0",
"async": "~2.3.0",
"debug": "~2.6.0",
"form-data": "~2.1.1",
"inflection": "~1.10.0",
"inflection": "~1.12.0",
"is-stream": "^1.1.0",

@@ -39,5 +39,5 @@ "path-proxy": "~1.0.0",

"devDependencies": {
"clone": "~1.0.0",
"clone": "~2.1.0",
"mailcomposer": "~2.1.0",
"mocha": "~3.0.2",
"mocha": "~3.2.0",
"request": "^2.67.0"

@@ -44,0 +44,0 @@ },

@@ -366,2 +366,44 @@ # mailgun.js

## Email Addresses validation
These routes require Mailgun public API key.
Please check Mailgun [email validation documentation](https://documentation.mailgun.com/api-email-validation.html) for more responses details.
### Validate one Email Address
Checks if email is valid.
Example usage:
```js
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
mailgun.validate('test@mail.com', function (err, body) {
if(body && body.is_valid){
// do something
}
});
```
### Parse Email Addresses list
Parses list of email addresses and returns two lists:
- parsed email addresses
- unparseable email addresses
Example usage:
```js
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
mailgun.parse([ 'test@mail.com', 'test2@mail.com' ], function (err, body) {
if(error){
// handle error
}else{
// do something with parsed addresses: body.parsed;
// do something with unparseable addresses: body.unparseable;
}
});
```
## Tests

@@ -368,0 +410,0 @@

@@ -1359,3 +1359,25 @@ var auth = require('./auth.json');

});
},
//
// Email Adresses Validation
//
'test mailgun.validate() should validate one email address': function (done) {
var mg = new mailgun.Mailgun({apiKey: auth.api_key, publicApiKey: auth.public_api_key, domain: auth.domain})
mg.validate('test@gmail.com', function (err, body) {
assert.ifError(err);
assert.ok(body);
done();
});
},
'test mailgun.parse() should parse list of email addresses': function (done) {
var mg = new mailgun.Mailgun({apiKey: auth.api_key, publicApiKey: auth.public_api_key, domain: auth.domain})
mg.parse([ 'testmg@gmail.com' ], function (err, body) {
assert.ifError(err);
assert.ok(body);
done();
});
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc