Send email when Survey is created
Opened this issue · 0 comments
DanielLarsenNZ commented
As a user, I would like to receive an email when I create a new Survey.
- Include Survey Link (bitly) and QR code.
- Use Mandrill + Powerdrill (NPM)
From @quipu :
api/services/EmailService.js
var email = require('powerdrill')(sails.config.mandrill_key);
module.exports = {
/**
* SEND A SIGN-UP CONFIRMATION EMAIL
* Email uses a template set up in Mandrill
* @param user
*/
signUpConfirm : function (user) {
var message = email();
message
.template('sign-up-confirmation')
.to(user.email, { fname : user.given_name });
message.send(function (err, resp) {
if(!resp[0]) {
sails.log.error('fn=EmailService.signUpConfirm status=fail msg="uncaught exception"');
return false;
}
if(resp[0].status != 'sent') {
sails.log.error('fn=EmailService.signUpConfirm status=fail msg="%s"', resp[0].reject_reason);
return false;
}
sails.log.debug('fn=EmailService.signUpConfirm status=success');
});
},