balderdashy / sails-hook-email

Sails email hook
67 stars 34 forks source link

ReferenceError: async is not defined #18

Closed Comkwatt closed 9 years ago

Comkwatt commented 9 years ago

Hi,

I'm juste trying to send a mail with this hook, with this code :

                     users.forEach(function(user){
                            if(user.submissionNotification){

                                sails.hooks.email.send('newSubmission', {
                                    recipentName : user.firstName,
                                    senderName: 'Welcome Marketing'
                                }, {
                                    to: user.eamil,
                                    subject: "Nouvelle Soumission"
                                }, function(err){
                                    console.log(err || 'Mail envoyé');
                                })

                            }
                        });

Sails raises me an error when i call sails.hooks.email.send

ReferenceError: async is not defined
    at Hook.Email.send (/Users/6po/Sites/WelcomeMarketing/WelcomeMarketingBackend/node_modules/sails-hook-email/index.js:161:7)
    at Hook.bound [as send] (/Users/6po/Sites/WelcomeMarketing/WelcomeMarketingBackend/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)

Do you've got an Idea ?

Comkwatt commented 9 years ago

I've solved the problem by adding two additional requires at the top of index.js of sails-hook-email

var async = require('async');
var _ = require('lodash');

I've created this pull request just in case : https://github.com/balderdashy/sails-hook-email/pull/19

sgress454 commented 9 years ago

Thanks @Comkwatt. Lodash and async are generally globalized by Sails but you can turn that off, so it's good to have them be explicit. Can you update your PR to add them as dependencies in the package.json file as well?

Comkwatt commented 9 years ago

Hi,

In fact I've not installed sails directly, but I've use this boilerplate and I didn't saw that some globals has been disabled : https://github.com/tarlepp/angular-sailsjs-boilerplate

Anyway if you want, I've updated my pull request :)

Have a nice day !

sgress454 commented 9 years ago

Closed by #19