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
Cron Error Output: [Symfony\Component\Debug\Exception\UndefinedFunctionException]
Attempted to call function “imap_search” from namespace “Mautic\EmailBundle\MonitoredEmail”.
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
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).
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
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
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!
I have php 8 IMAP working, it shows in the system info tab as enabled,
Any ideas on how I could trace this issue?
In Mailbox.php line 542:
[Symfony\Component\ErrorHandler\Error\UndefinedFunctionError]
Attempted to call function "imap_search" from namespace "Mautic\EmailBundle\MonitoredEmail".