Пытаюсь создать контактную форму и форму обратной связи для своего сайта. Вот мой маршрут и контроллер, которые я использую, однако мне нужно понять, что происходит с моими маршрутами и как захватить поля ввода из формы, реализующей это внутри MEAN.JS:
route.js
:
app.route('/mail').get(mail.createmail);
app/controller.js
:
exports.createmail = function(req, res) {
var mailOpts, smtpTrans;
// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: '[email protected]',
pass: '34Girls34*goo'
}
});
// NB! No need to recreate the transporter object. You can use
// the same transporter object for all e-mails
// setup e-mail data with unicode symbols
var mailOptions = {
from: 'Fred Foo ✔ <[email protected]>', // sender address
to: '[email protected]', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ✔', // plaintext body
html: '<b>Hello world ✔</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
} else {
console.log('Message sent: ' + info.response);
}
});
};
Не уверен, как это работает с HTML с представлением:
<form action="mail">...</form>