emailnext.jshostingnodemailer

Nodemailer with hostinger wrong auth


I am new to the whole sending emails through websites, so apologies.

Problem: I have a hostinger plan that has emails included. I'm using nodemailer to send the email. After a few tries I think the email will be sent if this error is solved. The config is OK, but it crashes on my auth: {}

 const transporter = nodemailer.createTransport({
  host: "smtp.hostinger.com",
  port: 465,
  secure: true,
  auth: {
    user: process.env.NEXT_PUBLIC_EMAIL_USERNAME,
    pass: process.env.NEXT_PUBLIC_EMAIL_PASSWORD,
  },
  tls: {
    rejectUnauthorized: false,
  },
});

The Error:

Error sending email: Error: Invalid login: 535 5.7.8 Error: authentication failed: 
    at SMTPConnection._formatError (webpack-internal:///(sc_server)/./node_modules/nodemailer/lib/smtp-connection/index.js:611:19)
    at SMTPConnection._actionAUTHComplete (webpack-internal:///(sc_server)/./node_modules/nodemailer/lib/smtp-connection/index.js:1221:34)
    at SMTPConnection.eval (webpack-internal:///(sc_server)/./node_modules/nodemailer/lib/smtp-connection/index.js:427:26)
    at SMTPConnection._processResponse (webpack-internal:///(sc_server)/./node_modules/nodemailer/lib/smtp-connection/index.js:748:20)
    at SMTPConnection._onData (webpack-internal:///(sc_server)/./node_modules/nodemailer/lib/smtp-connection/index.js:584:14)
    at TLSSocket.SMTPConnection._onSocketData (webpack-internal:///(sc_server)/./node_modules/nodemailer/lib/smtp-connection/index.js:143:48)
    at TLSSocket.emit (node:events:520:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
    at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 'EAUTH',
  response: '535 5.7.8 Error: authentication failed: ',
  responseCode: 535,
  command: 'AUTH PLAIN'
}

In my Hostinger plan I can create emails such as "info@domain.com", when logging into that email I am sent to "hostinger.titan.email/" with an email password combination to log in. I am using THAT email password in my

user: process.env.NEXT_PUBLIC_EMAIL_USERNAME,
pass: process.env.NEXT_PUBLIC_EMAIL_PASSWORD,

If anyone has experience with this, all info would be highly appreciated


Solution

  • For anyone having this problem, Hostinger is not the host, but Titan.

    Here is the correct config

    let transporter = nodemailer.createTransport({
    host: "smtp.titan.email",
    port: 465,
    secure: true,
    auth: {
    user: "test@domain.com",
    pass: "XXXXXXX",
    },
    });