'node.js imap not connection to ionos

I am using the "imap" package for connection to ionos server

const imap = new Imap({
        user: 'xxxxx',
        password: 'xxxxx',
        host: 'imap.ionos.com',
        port: 993,
        tls: true
});
...
imap.connect();

But I always get back this error, which is not really much.

Error: authentication failed
    at Connection._resTagged (/usr/src/app/node_modules/imap/lib/Connection.js:1502:11)
    at Parser.<anonymous> (/usr/src/app/node_modules/imap/lib/Connection.js:194:10)
    at Parser.emit (node:events:390:28)
    at Parser.emit (node:domain:475:12)
    at Parser._resTagged (/usr/src/app/node_modules/imap/lib/Parser.js:175:10)
    at Parser._parse (/usr/src/app/node_modules/imap/lib/Parser.js:139:16)
    at Parser._tryread (/usr/src/app/node_modules/imap/lib/Parser.js:82:15)
    at TLSSocket.Parser._cbReadable (/usr/src/app/node_modules/imap/lib/Parser.js:53:12)
    at TLSSocket.emit (node:events:390:28)
    at TLSSocket.emit (node:domain:475:12) {
  type: 'no',
  textCode: undefined,
  source: 'authentication'
}

I tried with the port 465 and 587 aswell and set tlsOptions rejectUnauthorized to false, but no effect. Same issue occurs on gmail. Anyone has ever experienced this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source