# Exception when attempting to process bounced email and monitored email box

**URL:** <https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228>\
**Category:** Product Support\
**Created:** [March 3, 2020, 11:38pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228 "2020-03-03T23:38:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [March 3, 2020, 11:38pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/1 "2020-03-03T23:38:56Z")

</div>

**Your software**  
My Mautic version is: 2.16  
My PHP version is: 7.3

**Your problem**  
My problem is: Exception when attempting to process bounced email and monitored email box

These errors are showing in the log:[Symfony\Component\Debug\Exception\UndefinedFunctionException]  
Attempted to call function “imap\_search” from namespace “Mautic\EmailBundle\MonitoredEmail”.

[2020-03-03 23:26:39] mautic.NOTICE: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined function Mautic\EmailBundle\MonitoredEmail\imap\_search() (uncaught exception) at Mautic/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php line 570 while running console command `mautic:email:fetch`

Steps I have tried to fix the problem: verified email credentials and cleared cache

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [March 6, 2020, 3:04pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/2 "2020-03-06T15:04:25Z")

</div>

Cron Error Output: [Symfony\Component\Debug\Exception\UndefinedFunctionException]  
Attempted to call function “imap\_search” from namespace “Mautic\EmailBundle\MonitoredEmail”.

mautic:email:fetch [-m|–message-limit [MESSAGE-LIMIT]] [-h|–help] [-q|–quiet] [-v|vv|vvv|–verbose] [-V|–version] [–ansi] [–no-ansi] [-n|–no-interaction] [-s|–shell] [–process-isolation] [-e|–env ENV] [–no-debug] [–]

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [March 9, 2020, 4:57pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/3 "2020-03-09T16:57:37Z")

</div>

More Debug Info-  
app/console mautic:emails:fetch --env=prod -vvv

[Symfony\Component\Debug\Exception\UndefinedFunctionException]  
Attempted to call function “imap\_search” from namespace “Mautic\EmailBundle\MonitoredEmail”.

Exception trace:  
() at /var/www/vhosts/mautic-install/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php:570  
Mautic\EmailBundle\MonitoredEmail\Mailbox-\>searchMailbox() at /var/www/vhosts/mautic-install/app/bundles/EmailBundle/MonitoredEmail/Fetcher.php:107

Mautic\EmailBundle\MonitoredEmail\Fetcher-\>fetch() at /var/www/vhosts/mautic-install/app/bundles/EmailBundle/Command/ProcessFetchEmailCommand.php:87

Mautic\EmailBundle\Command\ProcessFetchEmailCommand-\>execute() at /var/www/vhosts/mautic-install/vendor/symfony/console/Command/Command.php:242

Symfony\Component\Console\Command\Command-\>run() at /var/www/vhosts/mautic-install/vendor/symfony/console/Application.php:861

Symfony\Component\Console\Application-\>doRunCommand() at /var/www/vhosts/mautic-install/vendor/symfony/console/Application.php:193

Symfony\Component\Console\Application-\>doRun() at /var/www/vhosts/mautic-install/vendor/symfony/framework-bundle/Console/Application.php:84

Symfony\Bundle\FrameworkBundle\Console\Application-\>doRun() at /var/www/vhosts/mautic-install/vendor/symfony/console/Application.php:117

Symfony\Component\Console\Application-\>run() at /var/www/vhosts/mautic-install/app/console:41

---

<div class="post-metadata">

**Author:** ![autoize](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/autoize/32/105_2.png) [@autoize](https://forum.mautic.org/u/autoize)\
**Post date:** [March 9, 2020, 5:15pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/4 "2020-03-09T17:15:49Z")

</div>

Do you have the `php-imap` PHP module installed?  
Run the command `rpm -qa | grep php` (CentOS) or `dpkg -l | grep php` (Ubuntu) and see if it is listed.

If not, try installing it through the package manager  
`sudo apt install php-imap` (CentOS) or `sudo yum install php-imap` (Ubuntu)  
then restart your web server and the PHP-FPM process (if using PHP-FPM).

**Apache:** `sudo systemctl restart httpd` (CentOS)  
or `sudo systemctl restart apache2` (Ubuntu)  
**Nginx:** `sudo systemctl restart nginx`  
**PHP-FPM:** `sudo systemctl restart php-fpm`

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [March 9, 2020, 7:00pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/5 "2020-03-09T19:00:52Z")

</div>

PHP Warning: imap\_body(): supplied resource is not a valid imap resource in /var/www/vhosts-/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 965  
PHP Notice: Trying to get property ‘encoding’ of non-object in /var/www/vhosts/-/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 968  
PHP Notice: Trying to get property ‘encoding’ of non-object in /var/www/vhosts/-/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 970  
PHP Notice: Trying to get property ‘encoding’ of non-object in /var/www/vhosts/-/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 972  
PHP Notice: Trying to get property ‘encoding’ of non-object in /var/www/vhosts/-/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 974  
PHP Notice: Trying to get property ‘ifid’ of non-object in /var/www/vhosts/-/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 981

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [March 12, 2020, 4:54pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/6 "2020-03-12T16:54:48Z")

</div>

imap\_fetchheader(): Bad message number in /var/www/vhosts/mautic/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 869  
PHP Notice: Undefined property: stdClass::$from in /var/www/vhosts/mautic/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 878  
PHP Notice: Trying to get property ‘mailbox’ of non-object in /var/www/vhosts/mautic/app/bundles/EmailBundle/MonitoredEmail/Mailbox.php on line 878

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [June 11, 2020, 7:40pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/7 "2020-06-11T19:40:39Z")

</div>

> [@autoize](#):
>
> `rpm -qa | grep php`

php-imap-5.4.16-9.el7.x86\_64 is installed

---

<div class="post-metadata">

**Author:** ![autoize](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/autoize/32/105_2.png) [@autoize](https://forum.mautic.org/u/autoize)\
**Post date:** [June 16, 2020, 3:47pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/8 "2020-06-16T15:47:29Z")

</div>

5.4 is not supported anymore by Mautic.  
You need to upgrade PHP and its modules to PHP 7.2 or 7.3.

---

<div class="post-metadata">

**Author:** ![gaspar906](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gaspar906/32/838_2.png) [@gaspar906](https://forum.mautic.org/u/gaspar906)\
**Post date:** [July 30, 2020, 8:47pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/9 "2020-07-30T20:47:36Z")

</div>

I had the same issue, the problem is that the console could use a different folder or instance of PHP.

For instance, my mautic folder-project worked with PHP 7.2, but when I was in the console, the active PHP was 7.4 and this version of php did not have the imap library.

I just installed the imap library in php 7.4 and it works!

---

<div class="post-metadata">

**Author:** ![gaspar906](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gaspar906/32/838_2.png) [@gaspar906](https://forum.mautic.org/u/gaspar906)\
**Post date:** [July 30, 2020, 8:48pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/10 "2020-07-30T20:48:21Z")

</div>

php -v in the console to see the active php could works

---

<div class="post-metadata">

**Author:** ![ducanh98x](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ducanh98x/32/7955_2.png) [@ducanh98x](https://forum.mautic.org/u/ducanh98x)\
**Post date:** [July 20, 2022, 2:40pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/11 "2022-07-20T14:40:31Z")

</div>

I also got the same problem with EJL, anyone knows how to fix that?  
my email monitor login test was successful but I can’t fetch them on a cronjob

---

<div class="post-metadata">

**Author:** ![ezzat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ezzat/32/825_2.png) [@ezzat](https://forum.mautic.org/u/ezzat)\
**Post date:** [November 8, 2022, 12:45pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/12 "2022-11-08T12:45:05Z")

</div>

I am now experiencing this issue,

I have php 8 IMAP working, it shows in the system info tab as enabled,

Any ideas on how I could trace this issue?

```auto
In Mailbox.php line 542:
                                                                                                
  [Symfony\Component\ErrorHandler\Error\UndefinedFunctionError]                                 
  Attempted to call function "imap_search" from namespace "Mautic\EmailBundle\MonitoredEmail".  

```

[REDACTED]

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [November 8, 2022, 4:12pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/13 "2022-11-08T16:12:12Z")

</div>

php8 is not supported yet … need to be at php 7.4

---

<div class="post-metadata">

**Author:** ![ezzat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ezzat/32/825_2.png) [@ezzat](https://forum.mautic.org/u/ezzat)\
**Post date:** [November 8, 2022, 4:34pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/14 "2022-11-08T16:34:50Z")

</div>

I’m on 4.4 which release PHP 8 support, but either way, I upgraded to 8 to try to remedy the issue but it didn’t work, it started just the same at 7.4

---

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [November 8, 2022, 4:39pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/15 "2022-11-08T16:39:00Z")

</div>

I don’t remember about 4.4 supporting php8 then …

You could be right however I been seeing posts in here recommending to stay with 7.4 until Mautic 5 is released.

---

<div class="post-metadata">

**Author:** ![ezzat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ezzat/32/825_2.png) [@ezzat](https://forum.mautic.org/u/ezzat)\
**Post date:** [November 8, 2022, 8:33pm UTC](https://forum.mautic.org/t/exception-when-attempting-to-process-bounced-email-and-monitored-email-box/13228/16 "2022-11-08T20:33:19Z")

</div>

Here is that release

> **[Release Mautic Community 4.4.0 · mautic/mautic](https://github.com/mautic/mautic/releases/tag/4.4.0)**
>
> This is an out-of-cycle release which provides PHP 8.0 support to Mautic 4 users, and some other bug fixes. This should allow Mautic users to update their PHP versions before PHP 7 reaches end of l...

The issue still is not that one however, as PHP version does not fix the issue, now only seeing it with

```auto
 php /home/crm.grou.com/public_html/bin/console mautic:email:fetch -v

```
