Closed friktor closed 9 years ago
Hi friktor.....I am going to take a wild guess here and say the index.js with in the package is the hook. (now to figure out how to use it), I'll let you know how i get on :)
k so far..... I've done this, npm install sails-hook-email --save npm install sails-generate-hook --save sails generate hook email (generating the hook using the CLI may not be nessacary but I figured best stick with conventions when i have no idea WTF i'm doing).
AND THEN copy and paste the contents of "node_modules/sails-hook-email/index.js" in to "api/hooks/email/index.js".
hope this helps,
just had a wee look thought the index.js.... In lines 35 to 46 it looks like you put your test address in (for recieving emails???) so just fire your provider, address and password to find out. and a bit further down you'll see the name of the template directory to use (it's probally changeable) but if you stick with the defaults:
run this in the terminal from the project root mkdir views/emailTemplates in that direcory, make a file called html.ejs.... (put what you want in there i guess)
Hi again, Never mind editing the index.js... i think you can (possibly should) use a config file (called email.js) in your projects /config directory :) here's an example i made earlyer /config/email.js
module.exports.email = { service : 'gmail', auth : {user: "...", pass: "..."}, templateDir : '../../views/emailTemplates', from : 'test@this.net', testMode : true, alwaysSendTo : 'putYourTestEmailHere' };
You can find a list of nodemailer services here https://github.com/andris9/Nodemailer/blob/0.7/README.md#well-known-services-for-smtp for a list of service proiders'',
although it might not be neaded depending according to the above source.
either way once you've worked that one out.... back in the project root, terminal in the sails console command. (sails console) and type in the test script on the repo page :) sails.config.hooks.email( "testEmail", { recipientName: "Joe", senderName: "Sue" }, { to: "joe@example.com", subject: "Hi there" }, function(err) {console.log(err || "It worked!");} )
note: Mine did not work....
i got this in my console sails console
info: Starting app in interactive mode...
module.js:340
throw err;
^
Error: Cannot find module 'nodemailer'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.
km there's a fix for this and the next issue. npm install nodemailer --save npm uninstall sails-hook-email --save (guess we don't need two copies of it)
thanks! :+1: All works.
really? :D how?.. (mine didn't)
Hi @friktor @MarcMcIntosh and sorry I had no idea there were issues in this repo. My guess is that the Sails version you're lifting your app with is not up-to-date...try sails -v
and see what it says. It needs to be v0.10.6+ (current master version is v0.11.0-rc5). Then the instructions should work perfectly (just tested it myself on a fresh app).
Hi sgress, could have been :) I'm on v0.11.0-rc5 now, will give it another try soon (gonna dick-about with d3.js for a while)
Hmm, it appears that the way for installing hooks is currently unfinished if it takes the manual steps of creating api/hooks and copy/pasting from node modules to it.... @sgress454 is it that in 0.10.6+ sails automatically loads files with 'sails-hook-*' names in the /node_modules folder?
Also, do you guys intend to update NPM with a new version with hook support? It says no update for 5 months...
The way for installing hooks is completely finished, it's just not available in the build of Sails that's on NPM (v0.10.5). The version available on Github (v0.11) has this capability. It will install any modules in the node_modules
folder that have {"sails": {"isHook": true}}
in their package.json
file.
ahaaa, thanks. Yeah, I had the npm version and wasn't getting it. I'll try that out in the github one.
I install this via npm - after install Sails from Github (although the "master" branch no 0.10.6 - 0.10.5 only). After installation, using this plugin - ask that sails.hooks.email - "undefined". Going into the online documentation, I saw that the hooks can also install in api / hooks / - but after these actions I could not use the plugin. What is wrong?