IMAP\Connection is already closed when running bin/console mauticđź“§fetch

From the start I’ve had the log being stamped with IMAP\Connection is already closed when running bin/console mautic:email:fetch every time the cron job was running and there is a long standing ticket open for this issue and whether it’s a floater or not I can’t say since I’m new to Mautic since of v6.0.4. But, what I can say is that the issue and getting ride of the errors in the prod-log can be solved by what is suggested in ticker #14344 to change line 394 in /app/bundles/EmailBundle/MonitoredEmail/Mailbox.php from:

return $this->isConfigured() && $this->imapStream && @imap_ping($this->imapStream);

to:

return $this->isConfigured() && is_resource($this->imapStream) && @imap_ping($this->imapStream);

fixes the issue as well for us using v6.0.4.

Installation Details:

  • Mautic Version: 6.0.4

  • Apache: 2.4.6

  • PHP version: 8.2.29

  • Database: 10.11.14 (mariadb)

Thanks for sharing this workaround it’s really helpful! Replacing imap_ping() with is_resource($this->imapStream) on line 394 in Mailbox.php solved the “IMAP\Connection is already closed” error for me as well on Mautic 6.0.4.
For more context, you can also check this related discussion: Mauticfetch command not working – Mautic 6.0.2.

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.