WhatIsHTML
@WhatIsHTML
HTML программист

Как отправить письмо через Zoho и Nodemailer?

Вручную отправка почты и прием работает. Отправка через Nodemailer не работает - вылетает ошибка

spoiler
{ Error: Invalid login: 535 Authentication Failed
1|index    |     at SMTPConnection._formatError (/home/www.test.com/node_modules/nodemailer/lib/smtp-connection/index.js:606:19)
1|index    |     at SMTPConnection._actionAUTHComplete (/home/www.test.com/node_modules/nodemailer/lib/smtp-connection/index.js:1335:34)
1|index    |     at SMTPConnection._responseActions.push.str (/home/www.test.com/node_modules/nodemailer/lib/smtp-connection/index.js:366:26)
1|index    |     at SMTPConnection._processResponse (/home/www.test.com/node_modules/nodemailer/lib/smtp-connection/index.js:762:20)
1|index    |     at SMTPConnection._onData (/home/www.test.com/node_modules/nodemailer/lib/smtp-connection/index.js:558:14)
1|index    |     at TLSSocket._socket.on.chunk (/home/www.test.com/node_modules/nodemailer/lib/smtp-connection/index.js:510:47)
1|index    |     at TLSSocket.emit (events.js:182:13)
1|index    |     at TLSSocket.EventEmitter.emit (domain.js:442:20)
1|index    |     at addChunk (_stream_readable.js:280:12)
1|index    |     at readableAddChunk (_stream_readable.js:265:11)
1|index    |   code: 'EAUTH',
1|index    |   response: '535 Authentication Failed',
1|index    |   responseCode: 535,
1|index    |   command: 'AUTH PLAIN' }



Код
const nodemailer = require('nodemailer');
const config = require('./config');

function send(receiver, activateLink) {
  // create reusable transporter object using the default SMTP transport
  let transporter = nodemailer.createTransport({
    host: 'smtp.zoho.com',
    port: 465,
    secure: true,
    auth: {
      user: config.mailAdminAddress,
      pass: config.mailAdminPsw
    }
  });

  let mailOptions = {
    from: config.mailAdminAddress, // sender address
    to: receiver, // list of receivers
    subject: 'Confirm your account', // Subject line
    html: "Hello,<br> Please Click on the link to verify your email.<br><a href=" + activateLink + ">Click here to verify</a>"
  };

  // send actvation email
  transporter.sendMail(mailOptions, (error, info) => {
    if (error) {
      console.log(error);
    } else {
      console.log(info);
    }
  });

}

Делал по аналогии https://ourcodeworld.com/articles/read/264/how-to-...
  • Вопрос задан
  • 254 просмотра
Пригласить эксперта
Ответы на вопрос 1
WhatIsHTML
@WhatIsHTML Автор вопроса
HTML программист
Разобрался. Нужно поменять host на smtp.zoho.eu
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы