Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding email sending using html #13

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/emailjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ exportable = (function () {
options = options || {};

var template = templates[options.template];
var isHTML = options.isHTML;

if (!template) {
if (!template && !isHTML) {
return handleExcp(cb, 'Template not found: '+options.template);
}
if (!options.to || !options.subject) {
Expand All @@ -318,7 +319,7 @@ exportable = (function () {
}

options.from = options.from || defaultFrom;
renderMail(template, content)
renderMail(template, content, options)
.then(function (results) {
options.html = results.html;
options.text = results.text;
Expand Down Expand Up @@ -375,9 +376,13 @@ exportable = (function () {
return deferred.promise;
}

function renderMail (template, content) {
function renderMail (template, content, options) {
var deferred = Q.defer();

if (options.isHTML && content) {
console.log('---------- Allowed sending custom email --------------');
deferred.resolve(content);
return deferred.promise;
}
if (template) {
template.render(content, function (err, results) {
if (err) {
Expand Down Expand Up @@ -473,4 +478,4 @@ exportable = (function () {
return emailJS;
})();

module.exports = exports = exportable;
module.exports = exports = exportable;