-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
icfr
committed
Sep 22, 2016
1 parent
9a3159a
commit eea87fc
Showing
7 changed files
with
123 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"tags": { | ||
"allowUnknownTags": true, | ||
"dictionaries": ["jsdoc"] | ||
}, | ||
"source": { | ||
"include": ["./", "package.json", "readme.md"], | ||
"includePattern": ".js$", | ||
"excludePattern": "(node_modules/|docs/|test/)" | ||
}, | ||
"plugins": [ | ||
"plugins/markdown" | ||
], | ||
"templates": { | ||
"cleverLinks": false, | ||
"monospaceLinks": true, | ||
"useLongnameInNav": false | ||
}, | ||
"opts": { | ||
"destination": "/var/www/docs/", | ||
"encoding": "utf8", | ||
"private": true, | ||
"recurse": true, | ||
"template": "./node_modules/minami" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
'use strict'; | ||
/* global appdir,config,mailer */ | ||
// var console = require('debug-logger')('backworker:sendmail'); | ||
|
||
var Promise = require('bluebird'); | ||
var ECT = require('ect'); | ||
var defaults = require('lodash/defaults'); | ||
|
@@ -9,7 +10,26 @@ var renderer = ECT({ | |
root: appdir + '/resources/views/', | ||
ext: '.ect' | ||
}); | ||
|
||
/** | ||
* @constructor | ||
* @class | ||
* @classdesc send email compiled with ECT via {@link https://github.com/nodemailer/nodemailer|nodemailer} | ||
* @param {string} email email to send to | ||
* @param {string} subject email subject | ||
* @param {Object} data data to pass to ECT | ||
* @param {string} template template relative to resources/views/templates | ||
* @param {Object} options option added to mail | ||
* see {@link https://github.com/nodemailer/nodemailer#e-mail-message-fields|nodemailer email message fields} | ||
* @example | ||
* var Mail = require('laravel-queue/lib/Mail'); | ||
* var mail = new Mail('[email protected]', 'subject',{}, 'example'); | ||
* mail.send() | ||
* .then(function mailSuccess(res) { | ||
* // mail send succeffuly | ||
* }).catch(function mailError() { | ||
* // mail not send | ||
* }); | ||
*/ | ||
var Mail = function Mail(email, subject, data, template, options) { | ||
if (!config.mail) { | ||
throw new Error('mail not configured'); | ||
|
@@ -21,7 +41,11 @@ var Mail = function Mail(email, subject, data, template, options) { | |
this.template = template; | ||
this.options = options; | ||
}; | ||
|
||
/** | ||
* send email | ||
* @param {Function} callback callback called when send | ||
* @return {Promise} Bluebird promise | ||
*/ | ||
Mail.prototype.send = function sendMail(callback) { | ||
var mailTemplate = 'templates/' + this.template + '.ect'; | ||
var html = renderer.render(mailTemplate, this.content); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters