Я пытаюсь отправить электронное письмо с помощью nodejs. Я использовал этот плагин: https://nodemailer.com/about/, но я не получал почты.
Что я сделал не так?
Вот код и логи с сервера:
var express = require('express'),
app = express(),
nodeMailer = require('nodemailer'),
PORT = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.send('hello')
});
// Generate test SMTP service account from ethereal.email
// Only needed if you don't have a real mail account for testing
nodeMailer.createTestAccount((err, account) => {
// create reusable transporter object using the default SMTP transport
let transporter = nodeMailer.createTransport({
host: 'smtp.ethereal.email',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: account.user, // generated ethereal user
pass: account.pass // generated ethereal password
}
});
// setup email data with unicode symbols
let mailOptions = {
from: '"naveen sharma" <[email protected]>', // sender address
to: '[email protected]', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.info(error);
}
console.info('Message sent: %s', info.messageId);
// Preview only available when sending through an Ethereal account
console.info('Preview URL: %s', nodeMailer.getTestMessageUrl(info));
// Message sent: <[email protected]>
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
});
});
app.listen(PORT, () => {
console.info('listing to ', PORT);
});
ЖУРНАЛЫ
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
listing to 3000
Message sent: <[email protected]>
Preview URL: https://ethereal.email/message/W3Je0ho6KAyKJDkaW3Je1jX5zQzZ1TACAAAAARumoZhAa-nxhgOGHx1HBgA



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Вы отправляете свои сообщения через Эфирный, то есть:
… a fake SMTP service, mostly aimed at Nodemailer users (but not limited to). It's a completely free anti-transactional email service where messages never get delivered.
Если вы действительно хотите доставлять свои сообщения, вам нужно будет заплатить за учетную запись у реального поставщика услуг электронной почты.
любой другой способ отправить электронное письмо без оплаты, могу ли я использовать другой плагин узла