Email Trigger (IMAP): Search option argument must be a Date object or a parseable date string

Describe the problem/error/question

I’m trying to use node ‘Email Trigger (IMAP)"‘. Connection is successful, but when I’m trying to execute it, it always reports the following error:

Problem in node ‘Email Trigger (IMAP)’
Search option argument must be a Date object or a parseable date string

After some investigations with the help of AI, I found that the issue is that the node always adds

[“SINCE”,“Invalid DateTime”]

to the searchCriteria. Even when manually setting the option “Custom Email Rule” to [“UNSEEN”,[“SINCE”,“01-Aug-2025”]] it still appends the wrong SINCE with “Invalid DateTime”, so that there is one correct and one faulty SINCE entry which still makes the node fail. :frowning:

Then I did the following test which made the node work for a short time:
I manually logged into my n8n container with command “docker exec -u root -it n8n /bin/sh”, changed folder with command

$ cd /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/dist/nodes/EmailReadImap/v2/

edited a file via

$ vi EmailReadImapV2.node.js

and commented out the following line in the else statement so that it looks like this (to find it quickly search for the 2nd “push” in the code):

// searchCriteria.push([‘SINCE’, activatedAt.toFormat(‘dd-LLL-yyyy’)]);

Then I restarted the container

$ docker compose down ; docker compose up -d”.

When executing the “Email Trigger (IMAP)” node again, it worked perfectly!!!

Unfortunately, the container seems to reset to the original image after a while so that this workaround is only a very temporary solution. => I need the original container image to be fixed so that I can update my container.

What is the error message (if any)?

Error Message: see above

Extract from n8n debug log (I guess most interesting is the first line):

2025-08-16T21:06:16.487Z | debug | Querying for new messages on node “EmailReadImap” {“searchCriteria”:[“UNSEEN”,[“SINCE”,“Invalid DateTime”]],“file”:“EmailReadImapV2.node.js”,“function”:“onMail”}
2025-08-16T21:06:16.490Z | error | Email Read Imap node encountered an error fetching new emails {“error”:{“name”:“Error”,“message”:“Search option argument must be a Date object or a parseable date string”,“stack”:“Error: Search option argument must be a Date object or a parseable date string\n at buildSearchQuery (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Connection.js:1932:21)\n at Connection.search (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Connection.js:577:15)\n at Connection.search (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Connection.js:566:8)\n at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+imap@file+packages+@n8n+imap/node_modules/@n8n/imap/src/imap-simple.ts:73:14\n at new Promise ()\n at ImapSimple.search (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+imap@file+packages+@n8n+imap/node_modules/@n8n/imap/src/imap-simple.ts:72:16)\n at TriggerContext.getNewEmails (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/EmailReadImap/v2/utils.ts:114:34)\n at Connection.onMail (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts:399:27)\n at Connection.emit (node:events:530:35)\n at Connection._resUntagged (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Connection.js:1287:14)”},“file”:“EmailReadImapV2.node.js”,“function”:“onMail”}
2025-08-16T21:06:16.490Z | error | Search option argument must be a Date object or a parseable date string {“file”:“error-reporter.js”,“function”:“defaultReport”}
2025-08-16T21:06:16.490Z | debug | Running node “Email Trigger (IMAP)” finished with error {“node”:“Email Trigger (IMAP)”,“workflowId”:“Ti0M4kzXULU6AwRW”,“file”:“logger-proxy.js”,“function”:“exports.debug”}

Please share your workflow

Share the output returned by the last node

No output because of error; see above.

Information on your n8n setup

  • n8n version: 1.106.3 (installed from image “n8nio/n8n:latest” on 2025-Aug-16)
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Linux (from TrueNAS)

Ran your attached flow of one node, no error.
Which provider are you connecting to?

Hi Jabbson,

Thanks for the fast response.

Hmm, that it strange that it works for you, but not for me.

  • Which version of n8n are you using?
  • Are you also running it as local docker container?

The plan is to connect it to an AI Agent node… most probably with some preprocessing, data extraction and switching… but I didn’t do it yet, because the node keeps failing, except for a very short time after applying the workaround. So, connecting it to something else does not make sense yet.

BR,
Leupi73

Version 1.106.3

yes I do.

I was referring to the email provider. Which one you are connecting to from your IMAP node?

Ok, so you are using the same setup and n8n version.

I’m using email provider IONOS (f.k.a. 1&1 / Puretec) here in Germany, but I don’t think it’s an issue of the email provider, because the wrong substition is already done in n8n.

Why does n8n write [“SINCE”,“Invalid DateTime”] into the searchCriteria field.
I think it should be set with the date of last execution of that node. Maybe it’s not set, because it did not run successfully before, but in any case it should not use an invalid DateTime! It should leave it empty or set a correct default like “7 days ago” or something… and - of course - it should not append another SINCE value if I already added it in a Custom Email Rule.

Is there any way to check and manually set the last execution timestamp so that it can fetch a correct timestamp?

Other ideas what could have gone wrong?

it doesn’t, the error just shows which search criteria triggered the error.

i do, try using it for a different email provider, like gmail and see if that error persists.

Ok, will try with gmail… and will report back.

But why did it work, when I commented out the line that appends the SINCE value?
For me that is an indication that n8n sets something that is not valid. I might be wrong, but I don’t have a better explanation yet. :wink:

my guess this happens because IONOS expects a different date format.

The correct format is described in RFC 3501: INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1 as

date            = date-text / DQUOTE date-text DQUOTE

date-day        = 1*2DIGIT                    ; Day of month

date-month      = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
                  "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"

date-text       = date-day "-" date-month "-" date-year

date-year       = 4DIGIT

which all together compiles to (for today): 16-Aug-2025, which is exactly what dd-LLL-yyyy would produce.

I tried with GoogleMail but got the same error message.
So, I guess that’s another prove that its a strange n8n issue.

BTW: I also created another Email Trigger node, but got the same error.

When I did the dirty workaround, I simply suppressed adding the SINCE parameter and it worked.
I also tried manually setting SINCE in the format you mentioned and it also worked (once), before my manual change on the container was automatically reverted.

that the next best explanation for the issue, because it appears to be somehow related to your setup (the only other thread on the forum with that error was not related to email at all and happened when a person tried to format an empty string to date like so

That workflow works fine for me.

no it doesn’t, you are just working on the first output item, look at the second one.
Switch to Table or JSON output.

Try to print out the activatedAt value and see what it is:

else {
    this.logger.info(activatedAt);
    searchCriteria.push(['SINCE', activatedAt.toFormat('dd-LLL-yyyy')]);
}

restart your container, run the flow and see the docker logs.

The workflow ran successfully:

But - yes - the output values are “null”.

I just mean, that I didn’t get any error reported by n8n.

BTW: Now it gets even stranger:
After restarting my n8n instance I could run my IONOS Email Triggers several times successfully…
… BUT, when running another trigger and then trying the email trigger again, it fails. This is reproducible.

I tested the following:

  1. After restarting n8n it works fine. I opened my IONOS Email Trigger node and could “Execute Step” successfully many many times for more than a minute. Then I switched to the GMail Email Trigger and could also Execute Step successfully once…
    … but when executing it a 2nd time it started failing. Also switching back to the IONOS Trigger does not help, it also fails.
  2. I also tried executing a “When chat message received” node with attached workflow, which worked fine, but when going back and running the Email trigger again, the email trigger started failing again, while my chat workflow still works fine.

So, it seems as if something gets messed up when executing different nodes?
Strange!

Have you ever heard about something like this?

This is not how the execution looks for me:

Does this show the correct dates for you?

no, I don’t think i’ve seen anyone with similar problems.

Works only partly. :open_mouth:

So, there is a general timestamp issue on my system?

My docker-compose.yml looks like this:

services:

n8n:

image: n8nio/n8n:latest

container_name: n8n

restart: always

ports:

  - "5678:5678"

environment:

  - N8N_BASIC_AUTH_ACTIVE=true           # Enable basic auth for security

  - N8N_BASIC_AUTH_USER=admin            # Username for basic auth

  - N8N_BASIC_AUTH_PASSWORD="<password>"     # Password for basic auth (change this!)

  - N8N_HOST=192.168.3.3                 # Hostname, adjust if deployed on server

  - N8N_PORT=5678                        # Port n8n listens on

  - N8N_PROTOCOL=http                    # Change to https if using SSL termination

  - N8N_SECURE_COOKIE=false

  - DB_TYPE=sqlite                       # Using SQLite; can switch to other DBs if needed

  - DB_SQLITE_VACUUM_ON_STARTUP=false    # Optional DB maintenance

  - EXECUTIONS_PROCESS=main              # Process execution mode

  - GENERIC_TIMEZONE="Europe/Berlin"     # Setting local timezone

  - TZ="Europe/Berlin"                   # Setting local timezone

  - N8N_LOG_LEVEL=debug                  # Log level for debugging

  - N8N_LOG_OUTPUT=console,file          # Log output to console

  - N8N_LOG_FILE_LOCATION=/home/node/.n8n/n8n.log  # Log file location

  - N8N_LOG_FILE_MAX_SIZE=10000000       # Max log file size in bytes

volumes:

  - ../../docker-data/n8n/data:/home/node/.n8n

There is something wrong with luxon library in your n8n node environment, which is consistent with your error, since activatedAt variable was set from

const luxon_1 = require("luxon");
...
const activatedAt = luxon_1.DateTime.now();
...
searchCriteria.push(['SINCE', activatedAt.toFormat('dd-LLL-yyyy')]);

if luxon is broken const activatedAt = luxon_1.DateTime.now(); would end up being Invalid DateTime, which is then sent as a value of the SINCE filter criteria.

This is what it should look like:

Ok, but how come, because I’m using a container from vendor. Maybe even the same that you are using!?

stefan@nas2:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
n8nio/n8n latest 8947fc40553d 5 days ago 1.03GB