Spaces:
Running
Running
Update emails.js
Browse files
emails.js
CHANGED
@@ -211,12 +211,12 @@ async function sendEmail(req, res) {
|
|
211 |
emailsList.forEach(async (user) => {
|
212 |
|
213 |
const mailTemplate = craftEmailTemplate(user, newsList);
|
214 |
-
res.send(mailTemplate);
|
215 |
-
|
216 |
|
217 |
});
|
218 |
//const result = await sendEmail();
|
219 |
-
|
220 |
} catch (error) {
|
221 |
console.log(error);
|
222 |
res.status(500).send("Error sending email.");
|
|
|
211 |
emailsList.forEach(async (user) => {
|
212 |
|
213 |
const mailTemplate = craftEmailTemplate(user, newsList);
|
214 |
+
//res.send(mailTemplate);
|
215 |
+
await sendToUser(user.email, mailTemplate);
|
216 |
|
217 |
});
|
218 |
//const result = await sendEmail();
|
219 |
+
res.send({ "news": newsList, "emails": emailsList });
|
220 |
} catch (error) {
|
221 |
console.log(error);
|
222 |
res.status(500).send("Error sending email.");
|