Answer the question
In order to leave comments, you need to log in
How to remake the code so that it runs as a separate module?
It is not possible to transfer sending email to the module. This code is safely sent from app.js, but when trying to take it out as a separate module, it swears at app, which is logical (standard express.js architecture). Does anyone know what needs to be changed here?
var mailer = require('express-mailer');
router.get('/', function (req, res, next) {
mailer.extend(app, {
from: '[email protected]',
host: 'smtp.yandex.ru',
secureConnection: true,
port: 465,
transportMethod: 'SMTP',
auth: {
user: '[email protected]',
pass: 'password'
}
});
app.mailler.send('email', {
to: '[email protected]',
subject: 'test'
}, function (err) {
if (err) {
console.log('error');
return
}
res.send('email sent');
});
});
Answer the question
In order to leave comments, you need to log in
Probably because you don't have app, router variables defined. Maybe they need to be imported first?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question