mirror of
https://github.com/balkian/Hookio-Mailer.git
synced 2024-11-21 22:12:31 +00:00
First Commit
This commit is contained in:
commit
16a5c27759
13
bin/mailer
Normal file
13
bin/mailer
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var Hook = require('../lib/mailer').MailerHook;
|
||||||
|
|
||||||
|
var hook = new Hook({
|
||||||
|
name: "mailer"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Hook.start defaults to localhost
|
||||||
|
// it can accept dnode constructor options ( for remote connections )
|
||||||
|
// these hooks can be started on diffirent machines / networks / devices
|
||||||
|
hook.start();
|
7
config.json_example
Normal file
7
config.json_example
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"mailer": {
|
||||||
|
"host": "smtp.gmail.com",
|
||||||
|
"username": "BLABLA@gmail.com",
|
||||||
|
"password": "password"
|
||||||
|
}
|
||||||
|
}
|
57
lib/mailer.js
Normal file
57
lib/mailer.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// The modules this hook requires
|
||||||
|
var Hook = require('hook.io').Hook,
|
||||||
|
util = require('util'),
|
||||||
|
mailerModule = require('mailer');
|
||||||
|
|
||||||
|
// Things we need to access in different functions
|
||||||
|
|
||||||
|
// Set up the hook, and export it at the same time
|
||||||
|
var MailerHook = exports.MailerHook = function(options) {
|
||||||
|
var self = this;
|
||||||
|
Hook.call(self, options); // Basic initializations
|
||||||
|
self.config.use('file', { file: './config.json'});
|
||||||
|
|
||||||
|
// Register callback for hook::ready event
|
||||||
|
self.on('hook::ready', function() {
|
||||||
|
// When hook is ready, register callbacks for boxcar events
|
||||||
|
self.on('*::send', function(data) {
|
||||||
|
self.send(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set up inheritance from Hook
|
||||||
|
util.inherits(MailerHook, Hook);
|
||||||
|
|
||||||
|
// Callbacks defined below
|
||||||
|
|
||||||
|
MailerHook.prototype.send = function(options){
|
||||||
|
|
||||||
|
var self = this,
|
||||||
|
settings = self.config.get('mailer');
|
||||||
|
|
||||||
|
console.log("Settings: "+settings);
|
||||||
|
console.log("Options: "+options);
|
||||||
|
mailerModule.send({
|
||||||
|
ssl: true,
|
||||||
|
to: options.to,
|
||||||
|
from: options.from,
|
||||||
|
host: settings.host,
|
||||||
|
authentication: 'login',
|
||||||
|
username: settings.username,
|
||||||
|
password: settings.password,
|
||||||
|
domain: settings.domain,
|
||||||
|
subject: options.subject,
|
||||||
|
body: options.body
|
||||||
|
},
|
||||||
|
function(err, result){
|
||||||
|
if(err){
|
||||||
|
return self.emit('error', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.emit('emailSent', result);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
23
package.json
Normal file
23
package.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"author": "J.Fernando Sánchez <balkian@gmail.com>",
|
||||||
|
"name": "hook.io-mailer",
|
||||||
|
"description": "Hook for mail integration",
|
||||||
|
"keywords" : [ "hook", "hook.io", "calendar" ],
|
||||||
|
"version": "0.0.1",
|
||||||
|
"bugs" : { "url" : "http://github.com/balkian" },
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/balkian/hookio-mailer.git"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"hookio-calendar": "./bin/mailer"
|
||||||
|
},
|
||||||
|
"main": "./lib/mailer",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= v0.4.7"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"hook.io" : "0.8.x"
|
||||||
|
},
|
||||||
|
"devDependencies": {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user