Commit cbbda3e9 authored by Vytor Calixto's avatar Vytor Calixto 👾

Merge branch 'feature_send_email' into 'master'

Add Sending Mail Functionality

See merge request !2
parents 5b13bb59 c3b9a32f
Pipeline #11826 failed with stage
in 1 minute and 11 seconds
......@@ -34,6 +34,7 @@
"monetdb-pool": "0.0.8",
"mongoose": "^4.6.0",
"nconf": "^0.8.x",
"nodemailer": "^4.1.0",
"passport": "^0.3.2",
"winston": "^2.2.0"
},
......
const nodemailer = require('nodemailer');
let transporter = nodemailer.createTransport({
"port": 25,
"host": "mx.c3sl.ufpr.br",
"secure": false,
"ignoreTLS": true
});
let mailOptions = {
"from": "\"Laboratório de Dados Educacionais\" <lde@c3sl.ufpr.br>",
"to": "<dadoseducacionais@ufpr.br>"
};
module.exports = function send(content, callback) {
mailOptions.content = content;
transporter.sendMail(mailOptions, (err, info) => {
if (err)
return callback(err);
callback(null, info);
});
}
......@@ -10,6 +10,8 @@ const log = require(`${libs}/log`)(module);
const Message = require(`${libs}/models/message`);
const Email = require(`${libs}/middlewares/email`);
messageApp.get('/', (req, res, next) => {
Message.find((err, messages) => {
if(err) {
......@@ -56,6 +58,13 @@ messageApp.post('/', (req, res, next) => {
},
contents: req.body.contents
});
text = message.author.name + " <" + message.author.email +
"> enviou a seguinte mensagem via página de contato do LDE: \"" +
message.contents + "\"";
Email(text, (err)=> {
if (err)
log.error(err);
});
message.save((err) => {
if(err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment