Cannot get mails via IMAP

Hello,

I would like to get mails like mail client does. I tried via evolution (Linux mail client) and it works, but I do sth wrong when try do same in n8n.

This is config in mail client:
image
And this is what I provide to n8n:
image

My node:

{
  "nodes": [
    {
      "parameters": {
        "postProcessAction": "nothing",
        "options": {}
      },
      "name": "IMAP Email",
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 1,
      "position": [
        450,
        300
      ],
      "credentials": {
        "imap": {
          "id": "10",
          "name": "PWSTE"
        }
      }
    }
  ],
  "connections": {}
}

N8N error:

ERROR: 139865388739912:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

Error details:

Error: 139865388739912:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

    at Socket.ondata (internal/js_stream_socket.js:77:22)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

I do this first time, so is my way correct or is just not possibly or sth?

Thank you in advance :>

Hi @Shirobachi, I am sorry to hear you’re encountering this problem. I am not super familiar with IMAP security, but it seems in your email client you are using a STARTTLS encryption (which uses an insecure connection to start with and then negotiates an upgrade to a secure connection). In n8n you have selected SSL/TLS which requires a secure connection to start but which your server doesn’t seem to offer. So what happens here is that n8n would try to establish a secure connection to your IMAP server but this attempt ultimately fails.

Now from my understanding STARTTLS is no longer recommended by the Internet Engineering Task Force and is not supported by n8n’s IMAP credentials.

Therefore my suggestion would be to check if your email provider offers SSL/TLS connections (possibly through a different port as 993 would be the default port for encrypted IMAP) or sign up for an alternative email provider for your n8n use case.

I hope this makes sense and clarifies! Please do let me know if you have any further queries.

3 Likes

Thanks for that explanation, I did not know that difference b/w STARTTLS and SSL/TLS.

I checked it, and it worked, but TBH very weird loading.
#1: I mean that when I pass creds to evolution (mail client) it takes like max 1 second. The very same creds in n8n can take even minute with no result. At the beginning I got some result, so I can say that:

#2: I had in mailbox 3 mails, one new unread other old maked as read, and only new one was returned by n8n. How it exactly work? I mean, I know that it’s trigger node, but it’s returning only one the newest or somehow else?

I activated it and it work in background properly by now

My node:

{
  "nodes": [
    {
      "parameters": {
        "mailbox": "Inbox",
        "options": {}
      },
      "name": "Get mails",
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 1,
      "position": [
        -410,
        250
      ],
      "credentials": {
        "imap": {
          "id": "10",
          "name": "PWSTE"
        }
      }
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": "e6d56144-06ed-4ac6-9196-a72672264b8f",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "New student mail!"
            },
            {
              "key": "Date|date",
              "includeTime": false,
              "date": "={{$json[\"date\"]}}"
            },
            {
              "key": "URL|url",
              "urlValue": "https://poczta.s.pwste.edu.pl/"
            }
          ]
        }
      },
      "name": "Send info of mails",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 1,
      "position": [
        -210,
        250
      ],
      "executeOnce": true,
      "credentials": {
        "notionApi": {
          "id": "1",
          "name": "[email protected]"
        }
      }
    }
  ],
  "connections": {
    "Get mails": {
      "main": [
        [
          {
            "node": "Send info of mails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Creds:

For your question 1: This wouldn’t usually happen when using the IMAP trigger node - it opens a connection and then triggers whenever new mail arrives.

However, there could be a wait whenever the connection gets interrupted. You could configure your logging to see verbose output like this to verify this.

For your second question: That’s the default behaviour - it triggers for new, unseen mails and ignores other messages in your inbox (which could also cause the behavior from your first question when your email client is marking messages as seen automatically). You can customize this behaviour under Options → Custom email rules:

image

The node uses this module under the hood, so you’d need to familiarize yourself with the respective search functionality in case you want to adjust this behaviour.

1 Like