Всякий раз, когда я пытаюсь отправить электронное письмо со своего сервера, работающего локально, оно работает без проблем, однако в производственной среде происходит сбой.
Вот файл журнала:
at SMTPConnection._actionAUTHComplete (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:1335:34)
at SMTPConnection._responseActions.push.str (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:1293:18)
at SMTPConnection._processResponse (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:762:20)
at SMTPConnection._onData (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:558:14)
at TLSSocket._socket.on.chunk (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:709:51)
at TLSSocket.emit (events.js:182:13)
at TLSSocket.EventEmitter.emit (domain.js:442:20)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
code: 'EAUTH',
response:
'535 5.7.3 Authentication unsuccessful [YTOPR0101CA0050.CANPRD01.PROD.OUTLOOK.COM]', responseCode: 535, command: 'AUTH LOGIN' }
{ Error: Invalid login: 535 5.7.3 Authentication unsuccessful [YTXPR0101CA0004.CANPRD01.PROD.OUTLOOK.COM]
at SMTPConnection._formatError (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:606:19)
at SMTPConnection._actionAUTHComplete (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:1335:34)
at SMTPConnection._responseActions.push.str (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:1293:18)
at SMTPConnection._processResponse (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:762:20)
at SMTPConnection._onData (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:558:14)
at TLSSocket._socket.on.chunk (/home/7278/mailsender/node_modules/nodemailer/lib/smtp-connection/index.js:709:51)
at TLSSocket.emit (events.js:182:13)
at TLSSocket.EventEmitter.emit (domain.js:442:20)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
code: 'EAUTH',
response:
'535 5.7.3 Authentication unsuccessful [YTXPR0101CA0004.CANPRD01.PROD.OUTLOOK.COM]',
responseCode: 535,
command: 'AUTH LOGIN' }
Воткод для сервера node.js:
#!/usr/bin/env node
const http = require("http");
const url = require('url');
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'Hotmail',
auth: {
user: 'my email',
pass: 'my password'
},
});
const server = http.createServer(function (req, res) {
//console.log(res.getHeader("Message-Author"));
//Parse the address:
var q = url.parse(req.url, true);
/*The parse method returns an object containing url properties*/
/*The query property returns an object with all the querystring parameters as properties:*/
var qdata = q.query;
/*console.log(qdata.name);
console.log(qdata.email);
console.log(qdata.subject);
console.log(qdata.message);*/
var mailOptions = {
from: 'my email',
to: 'my email',
subject: '['+qdata.name+', '+qdata.email+']'+qdata.subject,
text: '[tag]\n\n'+qdata.message
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
res.writeHead(302, {
'Location': 'url here'
});
res.end();
});
server.listen(80, (err) => {
if ( ! err) {
console.log(`server is listening on 80`)
}
})
Я не знаю, почему он будет подключаться и отправлять электронную почту нормально при локальном запуске, но затем скажите мне, что Authentication unsuccessful
, когда сервер работает.Любая помощь / указатели будут оценены.