0.0.1 • Published 9 years ago
awesome-content-sender v0.0.1
Awesome Content Sender
This module provide a generic AwesomeModule which sends any contents using a sender. It comes with a precoded email-sender. This sender merges a content into a template then send it using the mailer. This mailer is a mandatory dependency and can be found here:
Exposed api
- registerSender(type, sender)
Store a new sender of type type. A minimal sender is as such:
module.exports = {
send: function(from, to, content, options) {
var deferred = require('q').defer();
// ...
// do whatever you want with from, to, content and options.
// ...
deferred.resolve();
return deferred.promise;
}
}
- send(from, to, content, options, type)
Send the content using the sender stored of type type. It only delegates to sender.send method.
Dependencies
- linagora.io.mailer: mandatory, it is used in the email-sender.
- logger: optional, it should at list exposed logger.info and logger.error, otherwise by default it is console.log.
- config: optional, it should at list exposed config.email.templateDir, otherwise by default it is ./templates.
The email-sender
This sender can be used with:
send(from, to, content, options, **'email'**)
- from: It is a tuple { objectype: {String}, id: {String} }
- to: It is a tuple { objectype: {String}, id: {String} }
- content: Any kind of object
- options: expected object is
{
template: {String}, mandatory,
message: {Object}
}
By default templateDir is ./templates. So you must have this directory at the root of your project as such:
| templates // templateDir
| -- invitation // options.template
| -- style.less
| -- html.jade
| -- digest // options.template
| -- style.less
| -- html.jade
| -- ...
0.0.1
9 years ago