# IMAP\\Connection is already closed when running bin/console mautic📧fetch

**URL:** <https://forum.mautic.org/t/imap-connection-is-already-closed-when-running-bin-console-mauticfetch/36492>\
**Category:** Mautic 6 Install/Upgrade Support\
**Created:** [September 8, 2025, 2:39pm UTC](https://forum.mautic.org/t/imap-connection-is-already-closed-when-running-bin-console-mauticfetch/36492 "2025-09-08T14:39:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtcusr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mtcusr/32/13386_2.png) [@mtcusr](https://forum.mautic.org/u/mtcusr)\
**Post date:** [September 8, 2025, 2:39pm UTC](https://forum.mautic.org/t/imap-connection-is-already-closed-when-running-bin-console-mauticfetch/36492/1 "2025-09-08T14:39:48Z")

</div>

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](https://github.com/mautic/mautic/issues/14344#issuecomment-3066288125) 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.

---

<div class="post-metadata">

**Author:** ![mtcusr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mtcusr/32/13386_2.png) [@mtcusr](https://forum.mautic.org/u/mtcusr)\
**Post date:** [September 8, 2025, 5:54pm UTC](https://forum.mautic.org/t/imap-connection-is-already-closed-when-running-bin-console-mauticfetch/36492/2 "2025-09-08T17:54:41Z")

</div>

Installation Details:

- Mautic Version: 6.0.4

- Apache: 2.4.6

- PHP version: 8.2.29

- Database: 10.11.14 (mariadb)

---

<div class="post-metadata">

**Author:** ![mattewwade06](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mattewwade06/32/14401_2.png) [@mattewwade06](https://forum.mautic.org/u/mattewwade06)\
**Post date:** [September 9, 2025, 9:12am UTC](https://forum.mautic.org/t/imap-connection-is-already-closed-when-running-bin-console-mauticfetch/36492/3 "2025-09-09T09:12:12Z")

</div>

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](https://forum.mautic.org/t/mauticfetch-command-not-working-mautic-6-0-2/35833?utm_source=chatgpt.com).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [September 10, 2025, 9:12pm UTC](https://forum.mautic.org/t/imap-connection-is-already-closed-when-running-bin-console-mauticfetch/36492/4 "2025-09-10T21:12:20Z")

</div>

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