forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.66k stars 339 forks source link

renderAll does not properly throw error #395

Closed matkev closed 4 years ago

matkev commented 4 years ago

This if statement at the end of renderAll won't properly throw an error, because message.attachments might never have been defined (because of: _.isArray(message.attachments)) if ( (!is.string(message.subject) || is.emptyStringOrWhitespace(message.subject)) && (!is.string(message.text) || is.emptyStringOrWhitespace(message.text)) && (!is.string(message.html) || is.emptyStringOrWhitespace(message.html)) && _.isArray(message.attachments) && _.isEmpty(message.attachments) ) throw new Error( No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "${template}" exist. );

Because of this, even if renderAll is called with an invalid templates path, and no message is constructed because no rendering was done, the error is not thrown.

niftylettuce commented 4 years ago

PR welcome

niftylettuce commented 4 years ago

v7.1.0 releasing to npm