Skip to content
Snippets Groups Projects
Commit 1c0d844a authored by ems19's avatar ems19
Browse files

[FIX] Email

parent 6ae7eaba
No related branches found
No related tags found
4 merge requests!391Hom -> Prod,!382[ADD] Email,!381Postgres migration,!380[ADD] Email route and fix Janaina Routes
......@@ -210,6 +210,6 @@ api.use('/publication', publication);
api.use('/activity', activity);
//Email
// api.use('/email', email);
api.use('/email', email);
module.exports = api;
......@@ -13,31 +13,11 @@ const User = require(`${libs}/models/user`);
const passport = require('passport');
emailApp.post('/', async (req, res, next) => {
var emails = await User.findAll({attributes:['email']});
emailApp.get('/', async (req, res, next) => {
var emails = await User.findAll({attributes:['name','email']});
const emailsArray = emails.map(_email => _email.get());
console.log(emailsArray);
var reqContents = req.body.contents
var sub = req.body.subject
let mailOptions = {
to: ["dadoseducacionais@ufpr.br", reqEmail],
from: `<dadoseducacionais@ufpr.br>`,
text: reqContents,
subject: sub,
bcc: emailsArray
}
email(mailOptions, (err, info) => {
if (err) {
log.error(err);
console.log(err);
res.status(500).json({ msg: 'Undelivered Contact Mail' });
} else {
log.info(`Message ${info.messageId} sent: ${info.response}`);
res.json({ msg: 'Contact Mail Successfully Delivered' });
}
});
res.json(emailsArray);
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment