Socket
Socket
Sign inDemoInstall

campaign

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

campaign - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

src/client/nodemailerClient.js

6

campaign.js

@@ -5,4 +5,5 @@ 'use strict';

var emailService = require('./src/emailService.js');
var consoleClient = require('./src/client/consoleClient.js');
var mandrillClient = require('./src/client/mandrillClient.js');
var consoleClient = require('./src/client/consoleClient.js');
var nodemailerClient = require('./src/client/nodemailerClient.js');

@@ -23,5 +24,6 @@ function api (options) {

console: consoleClient,
mandrill: mandrillClient
mandrill: mandrillClient,
nodemailer: nodemailerClient
};
module.exports = api;

@@ -0,3 +1,7 @@

# 1.0.1 Mailbox
- Out the box `nodemailer` client added
# 1.0.0 Dragon Fire
- Initial Public Release

@@ -14,3 +14,3 @@ {

},
"version": "1.0.0",
"version": "1.0.1",
"licenses": "MIT",

@@ -17,0 +17,0 @@ "keywords": [

@@ -20,2 +20,3 @@ ![campaign.png][9]

- [Debugging](#debugging)
- [Clients](#clients)
- [License](#license)

@@ -84,3 +85,3 @@

An optional `from` address can be provided, the `client` is responsible for trying to make it look like that's the send address.
The `from` address for our emails. The `client` is responsible for trying to make it look like that's the send address. Not necessarily used for authentication.

@@ -286,2 +287,4 @@ ### `client`

});
// build and send mails as usual
```

@@ -291,2 +294,57 @@

# Clients
There are a few clients you can use. The default client sends mails through [Mandrill][1]. There is also a `console` logging client, [explained above](#debugging), and a `nodemailer` client, detailed below.
### Using `nodemailer`
To use with `nodemailer`, simply use that client.
```js
var nodemailer = require('nodemailer');
var smtp = nodemailer.createTransport('SMTP', {
service: 'Gmail',
auth: {
user: 'gmail.user@gmail.com',
pass: 'userpass'
}
});
var campaign = require('campaign');
var client = campaign({
client: campaign.clients.nodemailer({
transport: smtp,
transform: function (options) {
// add whatever options you want,
// or return a completely different object
}
})
});
// build and send mails as usual
```
That's that.
### Making your own client
If the existing clients don't satisfy your needs, you may provide your own. The `client` option just needs to be an object with a `send` method. For an example, check out the [`nodemailer` client source code][10].
You can easily write your own email sender, like this.
```js
var campaign = require('campaign');
var client = campaign({
client: {
send: function (model, done) {
// use the data in the model to send your email messages
}
}
});
// build and send mails as usual
```
If you decide to go for your own client, `campaign` will still prove useful thanks to its templating features.
# License

@@ -306,1 +364,2 @@

[9]: http://i.imgur.com/cBFalWm.png
[10]: https://github.com/bevacqua/campaign/blob/master/src/client/nodemailerClient.js

@@ -75,3 +75,3 @@ 'use strict';

subject: model.subject,
from_email: options.from,
from_email: model.from,
from_name: model.social.name,

@@ -78,0 +78,0 @@ to: mapRecipients(model.to),

@@ -26,3 +26,3 @@ 'use strict';

async.apply(validation, model),
async.apply(hydrate, file, model, options.headerImage),
async.apply(hydrate, file, model, options),
async.apply(async.waterfall, [

@@ -29,0 +29,0 @@ async.apply(render, template, model),

@@ -40,3 +40,3 @@ 'use strict';

module.exports = function (template, model, header, done) {
module.exports = function (template, model, options, done) {

@@ -55,8 +55,9 @@ var defaultStyles = require('./dat/defaultStyles.json');

model.from = options.from;
model._template = template ? filename(template) : '(dynamic)';
async.parallel([
async.apply(cacheHeader, model, header),
async.apply(cacheHeader, model, options.headerImage),
async.apply(encodeImages, model)
], done);
};
'use strict';
// process.env.MANDRILL_APIKEY = '<redacted>';
process.env.MANDRILL_APIKEY = '<redacted>';

@@ -5,0 +5,0 @@ var campaign = require('../campaign.js');

@@ -5,3 +5,5 @@ 'use strict';

var client = campaign({
client: campaign.clients.console({ trap: true })
from: 'nicolasbevacqua@gmail.com',
trap: 'nicolasbevacqua@gmail.com',
client: campaign.clients.console()
});

@@ -8,0 +10,0 @@

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