_.each(users, function(user) { Mandrill.sendTemplate({ template_name: 'parkspot-free-spot', template_content: [{ name: 'username', content: user.attributes.firstName },{ name: 'date', content: date },{ name: 'spotNumber', content: freeSpotNumber }], message: { text: "Hello!", subject: "Parkspoty - free spot", from_email: "*****@*****.**", from_name: "Parkspoty", to: [{ email: user.attributes.email }] }, async: true },{ success: function(httpResponse) { response.success(true); }, error: function(httpResponse) { response.error(httpResponse); } }); });
allUsers.each(function(user, status) { Mandrill.sendTemplate({ template_name: 'parkspot-draw-reminder', template_content: [{ name: 'username', content: user.firstName }], message: { text: "Hello!", subject: "Parkspoty reminder", from_email: "*****@*****.**", from_name: "Parkspoty", to: [{ email: user.email }] }, async: true },{ success: function(httpResponse) { console.log(httpResponse); response.success("Emails sent to all users!"); }, error: function(httpResponse) { console.error(httpResponse); response.error(httpResponse); } }); });
success: function(userToMail) { Mandrill.sendTemplate({ template_name: 'parkspot-notification', template_content: [{ name: 'username', content: userToMail.attributes.firstName },{ name: 'message', content: customMessage },{ name: 'subject', content: subject }], message: { text: "Hello!", subject: subject, from_email: "*****@*****.**", from_name: "Parkspoty", to: [{ email: email }] }, async: true },{ success: function(httpResponse) { response.success(true); }, error: function(httpResponse) { response.error(httpResponse); } }); },
success: function(user) { if(!dev) { //si pas dev, alors envoi mail, sinon on ne fait rien Mandrill.sendTemplate({ "template_name": "confirmationsignuppdj", "template_content": [ { "name": "loginUser", "content": email }, { "name": "passwordUser", "content": password } ], message: { from_email: "*****@*****.**", from_name: "Plat du jour", to: [ { email: email, name: '' } ] }, async: true }, { success: function (httpResponse) { console.log(httpResponse); response.success("Email sent!"); }, error: function (httpResponse) { console.error(httpResponse); response.error("Uh oh, something went wrong"); } }); } res.redirect('/r/espace-restaurateur'); },