W
W
WhatIsHTML2018-06-01 13:59:41
Node.js
WhatIsHTML, 2018-06-01 13:59:41

How to send email with Zoho and Nodemailer?

Manually sending mail and receiving works. Sending via Nodemailer does not work - an error occurs

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' }


The code
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);
    }
  });

}

Did by analogy https://ourcodeworld.com/articles/read/264/how-to-...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WhatIsHTML, 2018-06-01
@WhatIsHTML

Understood. Change host to smtp.zoho.eu

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question