Open tskaggs opened 10 years ago
Hey Tim- guessing this is an adapter version issue. tbh I'm planning on rehashing this module as a hook instead of an adapter (since it's not really doing CRUD stuff)- would you hit me up on skype if you have a sec sometime? that'll make sure I remember to get back to ya (balderdashy)
On Mon, Jun 16, 2014 at 1:06 PM, Tim Skaggs notifications@github.com wrote:
I followed the README:
- Define Connection in connections.js
// Mandrill 'usemandrill': { adapter: 'sails-mandrill', // apiKey: process.env.MANDRILL_KEY, // the api key for your mandrill account apiKey: 'myAPIkey', from: { name: 'Team Me', email: 'me@myurl.me' } }
Add Connection to Model (Email.js) > connections: ['usemandrill'],
module.exports = { connections: ['usemandrill'] };
- Add function to Controller. (UserController.js)
Just to test, I add the function when user updates profile:
update: function (req, res, next) { User.update(req.param('id'), req.params.all(), function userUpdated (err) {
if (err) { return res.redirect('/user/edit/' + req.param('id')); } Email.send({ to: [{ name: 'My Name', email: 'email@email.com' }, { name: 'Team Me', email: 'info@myemail.me' }], subject: 'omg i love you guys!!1', html: 'I can\'t wait to see you all in Chicago<br/>' + 'I loe you so much!!!! ', text: 'text fallback goes here-- in case some recipients (let\'s say the Chipettes) can\'t receive HTML emails' }, function optionalCallback (err) { console.log('Email Sent!'); // If you need to wait to find out if the email was sent successfully, // or run some code once you know one way or the other, here's where you can do that. // If `err` is set, the send failed. Otherwise, we're good! }); res.redirect('/user/show/' + req.param('id')); });
I get the error:
/Projects/build/node_modules/sails-mongo/node_modules/mongodb/lib/mongodb/connection/base.js:245 throw message; ^ TypeError: Object #
has no method 'send' at userUpdated (/Projects/build/api/controllers/UserController.js:29:11) at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/update.js:216:9 at done (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:128:19) at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:25:16 at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:150:25 at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:151:44 at fn (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:98:5) at iterate (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:142:13) at Object.async.eachSeries (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:158:9) at Object.runner.afterUpdate (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:101:9) — Reply to this email directly or view it on GitHub https://github.com/mikermcneil/sails-mandrill/issues/4.
Mike McNeil founder http://balderdash.co
http://github.com/mikermcneil C O NFI DEN TIA L i nfo rma tion in tended only for t he addressee(s). If you are not the intended recipient, empl oyee or agent responsible for delivery to the intended recipient(s), please be aware that any review, dissemination, use,distribut ion or copying of this message and its contents is strictly prohibited. If you receive this email in error, ple ase notify the sender and destroy any paper or electronic copies immediately.
Yea I'll add you on Skype. Thanks
@mikermcneil would not it be good to use the nodemailer with email-templates for email template support in ejs ?
I made some tests and is working well as Services but i want it work like plugin ... https://github.com/wejs/we/blob/master/api/services/EmailService.js
Mike If you show a good way to use Hooks to plug a feature (plugin?) i could develop and maintain this module ( as npm? ) ...
I'll need to improve my code to send email in coming weeks then i could take the time to contribute in this feature for the community ...
Updates on this? I've just installed this package and got the same error.
Hey, I solved this issue by changing this (using sailjs version 0.10.5:
module.exports = {
connections: ['usemandrill']
};
to this:
module.exports = {
connection: ['usemandrill']
};
Thank you @rkyleg !
I followed the README:
Just to test, I add the function when user updates profile:
I get the error: