IMAP Trigger drops error "'toLowerCase' and does not fetch any emails from INBOX, but from sub-INBOX folder

Hey n8n-ters,

in the most recent n8n self hosting version (even tested down to 2.35.1) the IMAP Trigger drops the following error on the Docker console and does not fetch any emails from INBOX, but works fine from any sub-INBOX folder (like INBOX/whatever).

Testet with a brand new workflow with just the IMAP Trigger node.

Error message on Docker Log:

Cannot read properties of null (reading ‘toLowerCase’)

TypeError: Cannot read properties of null (reading ‘toLowerCase’)

at parseBodyStructure (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:496:24)

at parseBodyStructure (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:524:23)

at parseBodyStructure (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:472:18)

at parseBodyStructure (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:466:13)

at Parser.parseFetch (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:440:13)

at Parser._resUntagged (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:257:24)

at Parser._parse (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:137:16)

at Parser._tryread (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:82:15)

at Parser._parse (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:162:10)

at Parser._tryread (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Parser.js:82:15)

Any suggestions?

Hey @DaGloom, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@achamm, @barn4k, @Anshul_Namdev - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

@DaGloom i would make a sub one for testing, if it works, slowly move emails into the main. And try it until you find an email that breaks it. I think its a Indianapolis email breaking the structure.

Hi @DaGloom,

This is not related to the toLowerCase() expression. The error comes from the underlying IMAP parser while reading an email’s MIME structure.

Because INBOX fails but a subfolder works, one email in INBOX is probably malformed.

Try moving emails out of INBOX in batches until the trigger works again. Then move them back in smaller batches to find the problematic message. Repair or remove that email, or use a clean folder temporarily.

Changing RAW/Simple/Resolved probably won’t help because the node still requests the message structure in each format.

Please also share your mail provider and exact n8n version if you want to report this upstream.

Hey @DaGloom Welcome to the n8n community!!

Your stack trace narrows it further than “some email is malformed”. Frame 524 of that Parser.js is the branch for a message/rfc822 part, so the message breaking INBOX is one with another email attached inside it (forwarded as an attachment, or a .eml), and line 496 is the parser calling toLowerCase on a NIL media type inside that attached email’s structure. Look for those first rather than bisecting the whole folder.

Until you find it you can keep the trigger running without touching the mailbox. In the node’s Custom Email Rules put [“UNSEEN”, [“SINCE”, “September 14, 2026”]] so it never fetches the old message at all, and walk the date backwards until it breaks, which also tells you when it arrived. That’s node-imap’s own search syntax and the node passes it straight through.

The parser is node-imap, unmaintained since 2016, with this exact crash reported upstream in 2019 and never fixed. n8n has an open PR replacing it with imapflow:

Hey, thanks for the fast response.

You were all right! It was an email, that stuck in the INBOX and blocked everything.

Strange to see that, because it came from a known mailer daemon, that reports for “over quota” of a recipient…

Well, thank you again and have a nice day!