Checking for e-mails when no user are active?

It looks like this design is flawed.
My web app should check for new e-mails regularly (every 5 minutes). Manually, it works, though I still have to find how I can tell imap to move an email to another folder once done.

I was about to implement the automatic check with a Timer, but realised it would only work when at least one user is actively using the app (and when several are, each would check for emails in the background).

Basically, I’d have to keep one session running all the time. This triggered me a question: what does a web app do when no user at all is connected to it? Does it sleep or is something still running?
What would be the best way to keep a session (or at least, a thread) always running?

Do you have a timer per session?

please have one global in your app.

1 Like

Ah, good idea, thank you.

BTW: I’ve searched in your plugins’ examples about how to move an e-mail from one folder/mailbox to another but found nothing. Using CURL, I’m not sure I can send commands to IMAP servers (I’ve seen only for FTP commands).
Do you happen to know whether it’s doable with your plugins?

It can be done easily.
Make a request via IMAP with OptionCustomRequest e.g.

"MOVE 1 INBOX.test"
to move first email to test folder. or

"UID MOVE 1234 INBOX.test"
to move email by UID to test, which may be better.

1 Like

Thank you very much!

1 Like