Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(function (resolve, reject) {
var email = new sendgrid.Email();
email.addTo(options.to);
email.subject = options.subject;
email.from = options.from || sails.config.sendgrid.sender;
if (typeof options.substitutions !== 'undefined' && options.substitutions) {
Enumerable.forEach(substitions, function(val,i) {
email.addSubstitution(val[0], val[1]);
});
}
if (typeof options.template === 'string' && options.template.length > 0) {
email.addFilter('templates', 'enable', 1);
email.addFilter('templates', 'template_id', options.template);
}
else {
email.text = ' ';
if (typeof options.text === 'string' && options.text.length > 0)
email.text = options.text;
email.html = ' ';
if (typeof options.html === 'string' && options.html.length > 0)
email.html = options.html;
else