Hello :)
I am running keystonejs and using the handlebars templating engine. I would like to integrate Mandrill to send out notification emails when someone sends an enquiry but the following happens:
- The post is successful and recorded
- I can view the enquiry in the admin ui
- The Mandrill API log does NOT show an API call failing or being successful
- No email is sent
I have in my keystone.js file the following in the init call:
// some options above
'custom engine': handlebars.create({
layoutsDir: 'templates/views/layouts',
partialsDir: 'templates/views/partials',
defaultLayout: 'default',
helpers: new require('./templates/views/helpers')(),
extname: '.hbs'
}).engine,
'auto update': true,
'emails': 'templates/emails',
'mandrill api key': 'my api key',
'mandrill username': 'my username',
// some options below
and in my Enquiry.js file I have the following:
Enquiry.schema.methods.sendNotificationEmail = function(callback) {
if ('function' !== typeof callback) {
callback = function() {};
}
var enquiry = this;
keystone.list('User').model.find().where('isAdmin', true).exec(function(err, admins) {
if (err) return callback(err);
new keystone.Email('enquiry-notification').send({
to: admins,
from: {
name: 'Kat Bella',
email: 'm...@email.com'
},
subject: 'New Inquiry for Kat Bella',
enquiry: enquiry
}, callback);
});
};
At Jed Watson's suggestion, I swapped out the above send method for the following:
new keystone.Email('enquiry-notification').send({
subject: 'New Inquiry for Kat Bella',
to: 'me@email.com',
fromName: 'Kat Bella',
fromEmail: 'm...@email.com',
enquiry: enquiry
}, callback);
Still no luck. I would appreciate any input on what I am doing wrong. Thanks!