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.67k stars 337 forks source link

send succeeds even if template directory exist #332

Closed mramato closed 5 years ago

mramato commented 6 years ago

I have the following code, which works perfectly:

const email = new Email({
    transport: sendEmail.transporter,
    juice: true,
    juiceResources: {
        preserveImportant: true,
        webResources: {
            relativeTo: path.resolve('emails')
        }
    },
    send: true,
    views: {
        options: {
            extension: 'hbs'
        }
    }
});

return email.send({
    template: templateName,
    message: {
        to: emailAddress
    },
    locals: bindings
});

The problem is that if someone typos templateName to a directory that doesn't exist, email.send just sends a blank message instead of rejecting the promise.

Is there a way to tell it to reject if the template is invalid or not found?

JigSawFr commented 5 years ago

Hi, Same problem :/

niftylettuce commented 5 years ago

This must be a bug with the new version, I will take a look. Sorry about that.

niftylettuce commented 5 years ago

will be published in new version shortly, thanks

niftylettuce commented 5 years ago

email-templates@5.0.2 has been released to npm

mramato commented 5 years ago

Thanks for the quick fix, @niftylettuce.