First stab at sending an e-mail
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* @description :: A short summary of how this model works and what it represents.
|
||||
* @docs :: http://sailsjs.org/#!documentation/models
|
||||
*/
|
||||
var nodemailer = require('nodemailer');
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -28,6 +29,36 @@ module.exports = {
|
||||
type: 'url'
|
||||
},
|
||||
restaurant: 'string'
|
||||
},
|
||||
|
||||
beforeCreate: function(values, next) {
|
||||
var transport = nodemailer.createTransport('SMTP', {
|
||||
service: "Gmail",
|
||||
auth: {
|
||||
user: "ben.ramey@gmail.com",
|
||||
pass: "Mila(18)?"
|
||||
}
|
||||
});
|
||||
|
||||
var inviteeEmails = [];
|
||||
for (var i in values.invitees) {
|
||||
inviteeEmails.push(i.email);
|
||||
}
|
||||
var options = {
|
||||
from: values.creatorName + " <" + values.creatorEmail + ">",
|
||||
to: inviteeEmails
|
||||
};
|
||||
transport.sendMail(options, function(err, response) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log("message sent from: " + values.creatorEmail);
|
||||
}
|
||||
});
|
||||
|
||||
transport.close();
|
||||
|
||||
next();
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user