Email Read IMAP Node works sometimes

Hi Everyone,

I have set up the ‘Email Read IMAP’ node to ‘watch’ an office 365 folder for incoming emails. About 50% of the time when a new email comes in the node triggers correctly and the new email is marked as read which is fine. But the other 50% of the time the node does not trigger and the emails remain marked as unread.

To rectify this I then deactivate and then re-activate the workflow and the emails are marked as read and the node triggers correctly.

Could someone please suggest what might be going on please?

Thank you!

Paul

Sadly not. Do you have any more information when that happens?

Like is it only a problem when n8n restarts or does it also happen when it is already running. If the later, does that normally then start to happen after a certain amount of time and if so how long around? Does it stop working after it got triggered by an email and then stops working or could can it also be the very first one? …?

Literally anything could be helpful to figure out what could be going wrong there.

Hi Jan,

I am using a vultr virtual server and n8n is running 24/7 and I would say adding fail2ban helped keep the server from crashing and at the same time we added n8n as a service so if a restart did take place n8n would be working straight away. Before those changes the server was crashing about once a day and needed to be restarted. I find the imap email node works for about a day at a time so could it be a server restart is causing the imap node to not pick up on the new emails. Does this help you at all?

Kind regards

Paul

Hey @Paul_Clarke,
From your last post, it is sounding like your n8n server may be under attack. fail2ban is a very good start but it’s focus is SSH. Your other ports are probably still wide open with limited security on them.

A few ideas to help you along:

  1. Set up a VPN or SSH tunnelling to the server to provide encrypted, limited access to the actual n8n installation
  2. Set up a firewall to limit and restrict access to only internal connection (127.0.0.1/localhost)
    • If using webhooks, limit access to the webhook to only the services that require the service. This can be done from the firewall based on specific IP ranges
  3. Disable ping responses from your server

I realize that none of these things are specifically n8n related but it is important to ensure that you server is safe first before moving on to troubleshooting specific services. Otherwise, you are battling every single person on the internet who decides they want to run the latest exploit tool against a range of addresses.

Hope this helps.

Hi there, shimming in as I am facing the same issue.

I use the IMAP node to connect to a G Suite account through their IMAP feature (disabled by default) and it works well if I receive an email soon after enabling the workflow. When I get an email a few days later, it doesn’t trigger until I turn it off then on again.

I can confirm my VM running n8n was not attacked or even rebooted, in fact the IMAP node worked well while our G Suite emails were still self-hosted on a Zimbra installation. This appears to be specific to actors like Google and certainly Microsoft, maybe there is a timeout on IMAP connections and n8n doesn’t automatically reconnect. I ignore if it uses the push IMAP feature or not, but if it’s waiting for a push while it’s really disconnected it won’t ever happen.

If there is a way I can provide relevant logs (nothing in the console afaik) let me know and I’ll try to contribute to the best of my abilities, the IMAP node is really helpful although not as advanced as Zapier’s or Huginn’s if we remain among self-hosted automation platforms.

Best regards,
Dylan

I am unfortunately experiencing the same issue with an Exchange Online hosted IMAP mailbox.

I’m also still facing (n8n 0.110.3) the same issue with the IMAP node.

It just stops working at some point.

This has, not so trivial, detrimental effects on the production ecosystem.

I realised only today that a workflow (among a hundred others) had been inactive for the past 3 days only because the IMAP trigger wasn’t functioning.

I hate to have to say this, but the same is happening to me.
There’s clearly a problem with IMAP Read Email node, and it’s going to be really hard to debug.

As a first step, I would suggest to log any interruption in the imap connection. At least that, so that those who can manage logs, can create alerts to notify us and better identify the problem.

1 Like

Ah yes, there is definitely something wrong with the IMAP node. We already tried to debug (mainly @krynble ) and like you also said is it not very easy. But it looks like the issue is the underlying library that the node uses. It does seem neither to reconnect when the connection gets interrupted nor does it send an event or some kind of error. Looks like at some point a rewrite is needed with a different library that does not have those issues.

Hi,

Is there any update about this issue?

Hello everyone.

I implemented a possible fix for this. Can you please give it a try? You can find it in this branch: Fix attempt to reconnect and make IMAP node stable by krynble · Pull Request #1667 · n8n-io/n8n · GitHub

Considering this error is hard to reproduce (happens only occasionally) I am not 100% sure if it works, but it’s a step toward fixing it.

I would appreciate your feedback about it if you test it.

1 Like

The possible fix got released with [email protected]

Please test and give feedback. Thanks a lot!

I’m currently in the process of testing and today I woke up to unread e-mails in the monitored inbox and no executions in n8n :frowning:

FWIW: I have also been having trouble with my internet connection here (switching providers in a few weeks). Not sure if that is relevant

Yeah I can confirm @SupersonicWaffle 's words.
Since yesterday night that the process stopped to process emails. Had to restart it today.

It seems that the fix improved something since it took a longer time than usual for the node to die, so that’s something.

I’m also discovering the same issue, having just started using the IMAP node yesterday.

Even I’ve been facing this issue and I’ve figured a small work around for this issue using n8n again.

I’ve setup another workflow which basically activates the workflow using the Cron trigger on a given time every day. I know this is not ideal, but this is atleast saving me time by not worrying about the emails not being read.

Here’s the workflow for someone who’s interested:

1 Like

Under the consideration, that’s actually a very good workaround. Ofc it’s not ideal, but should be able to fix our problems. Thanks for the tip!

Hi @all.
There is a fix available for this issue.
https://github.com/n8n-io/n8n/issues/1400

3 Likes

That’s amazing news, huge thanks to everyone involved

2 Likes

Hey all!

I am going to mark this as solved since it looks like the problem is now fixed. But if you still face any issues feel free to share :slight_smile: