Name in mail

This commit is contained in:
Thomas FORGIONE 2015-08-29 16:33:58 +02:00
parent 74cad3824b
commit 6fecbd8898
1 changed files with 23 additions and 9 deletions

View File

@ -1,3 +1,5 @@
var pg = require('pg');
var pgc = require('../../private.js');
var mail = require('../../lib/mail.js'); var mail = require('../../lib/mail.js');
var Log = require('../../lib/NodeLog.js'); var Log = require('../../lib/NodeLog.js');
@ -9,15 +11,27 @@ module.exports.index = function(req, res) {
text += i + ' : ' + req.body[i] + '\n'; text += i + ' : ' + req.body[i] + '\n';
} }
mail.send({ pg.connect(pgc.url, function(err, client, release) {
from: req.session.user_id + " <" + req.session.user_id + "@toto.tata>",
to: "Thomas <dragonrock.django@gmail.com>", client.query(
subject: "By " + req.session.user_id, 'SELECT Users.worker_id AS name FROM Users WHERE Users.id = $1;',
text: text [req.session.userId],
}, function(err, message) {
if (err !== null) { function(err, result) {
Log.mailerror(err); mail.send({
} from: result.rows[0].name + " <" + req.session.userId + "@toto.tata>",
to: "Thomas <dragonrock.django@gmail.com>",
subject: "By " + result.rows[0].name,
text: text
}, function(err, message) {
if (err !== null) {
Log.mailerror(err);
}
});
}
);
}); });
res.redirect('/thankyou'); res.redirect('/thankyou');