This is likely related to some kind of Dovecot bug.
If, while alps has an open IMAP connection, another client marks a message as \Deleted and then EXPUNGES it, alps will still receive the message on the next FETCH (and STATUS, interestingly), with the \Deleted flag set and the envelope missing. I've written aaa30ead41532fa920f3c5e0298ed52196d7fe3a which prevents the template from crashing in this situation, but at some point we should do a deeper investigation on the problem.
This does not occur on Rainloop which uses the same IMAP server in our context. I have a feeling some caching happens inside of our code.
Does Rainloop keep the IMAP connection open between requests?
PHP cannot do that asfik.
Yeah, that's an important part of the reproduction steps. I've already isolated the problem to the IMAP server. It seems like Dovecot has had similar issues before.
If we receive the message with the \Deleted flag, we should simply skip it and not show it, which would solve it?
We could do that, but it would be a workaround - wouldn't it be better to investigate and determine the root cause?
I put in a workaround. Closing this ticket as any issues with IMAP wouldn't be alps bugs.