postalsys / imapflow

IMAP Client library for EmailEngine Email API (https://emailengine.app)
https://imapflow.com
Other
368 stars 64 forks source link

Posteo.de `await client.connect()` never concludes #215

Closed benjaminpreiss closed 2 months ago

benjaminpreiss commented 2 months ago

Describe the bug Promise await client.connect() never concludes when connecting to posteo.de IMAP via port 993, TLS.

To Reproduce Steps to reproduce the behavior:

Execute the following script (e.g. with bun JS in my case):

import { ImapFlow } from "imapflow";
import { processMails } from "./mails";

export async function main() {
    const imapFlowClient = new ImapFlow({
        host: "posteo.de",
        port: 993,
        secure: true,
        auth: {
            user: "your-posteo-user-name",
            pass: "your-posteo-user-pass",
        },
        logger: {
            debug(obj) {
                console.log(obj);
            },
            error(obj) {
                console.error(obj);
            },
            info(obj) {
                console.log(obj);
            },
            warn(obj) {
                console.log(obj);
            },
        },
        tls: {
            rejectUnauthorized: false,
            minVersion: "TLSv1.2",
        },
        servername: "posteo.de",
        emitLogs: true,
        disableAutoIdle: true,
        verifyOnly: true,
    });

    await imapFlowClient.connect();
    console.log("after connect");
    await imapFlowClient.logout();
}

When using bun, execute the above script with bun ./path/to/file.ts.

In my case, I get the following logs:

{
  src: "connection",
  msg: "Established secure TCP connection",
  cid: "erf23i15no1o0c1fnv6p",
  secure: true,
  host: "posteo.de",
  servername: "posteo.de",
  port: 993,
  address: "2a05:bc0:1000:80::169:1",
  localAddress: "127.0.0.1",
  localPort: 55720,
  authorized: false,
  algo: "TLS_AES_256_GCM_SHA384",
  version: "TLSv1/SSLv3",
}
{
  src: "s",
  msg: "* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.",
  cid: "erf23i15no1o0c1fnv6p",
  nullBytesRemoved: undefined,
}
{
  src: "s",
  msg: "1 ID (\"name\" \"imapflow\" \"version\" \"1.0.164\" \"vendor\" \"Postal Systems\" \"support-url\" \"https://github.com/postalsys/imapflow/issues\")",
  cid: "erf23i15no1o0c1fnv6p",
  comment: undefined,
}
{
  src: "s",
  msg: "* ID (\"name\" \"Dovecot\")",
  cid: "erf23i15no1o0c1fnv6p",
  nullBytesRemoved: undefined,
}

What's suspicious to me: version: "TLSv1/SSLv3", which makes me guess whether my TLS version config on the imapflow client takes effect.

Posteo states on their website, that TLS 1.0 connections will be rejected: https://posteo.de/en/help/how-do-i-set-up-posteo-in-an-email-client-pop3-imap-and-smtp

Expected behavior I expect to see after connect in my console eventually.

Desktop (please complete the following information):

andris9 commented 2 months ago

Does it work with Node?

benjaminpreiss commented 2 months ago

Does it work with Node?

Instead of executing it with bun? Indeed!

Getting a connection now, when executing with node.

Maybe the reason is missing compatibility with node:tls on bun? https://bun.sh/docs/runtime/nodejs-apis

benjaminpreiss commented 2 months ago

Closing this issue as this seems related to bun.