My Mautic version is: 3.1.1
My PHP version is: 7.3.21
My Database type and version is: 10.2.33-MariaDB-log - MariaDB Server
My problem is:
Sending an email to contact via mautic api
$email = $emailApi->sendToContact($emailId, $contactId);
returns 500 error code.
These errors are showing in the log:
In Mautic error log:
mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: “Error: Illegal length modifier specified ‘f’ in s[np]printf call” at /[mauticInstallPath]/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php line 101
Looked at StreamHandler.php line 101 which is:
$this->stream = fopen($this->url, ‘a’);
Steps I have tried to fix the problem:
Tried to see if it was an issue with Sending emails. Tested the following methods and they all work:
- Sending emails to contact directly via the mautic interface works fine.
- Sent test email via mautic configuration - email settings works fine.
- Sent email via Mautic api to segment using $email = $emailApi->send($id); works.
I have also tried clearing the cache, but error persist.
Any help is much appreciated.
This seems to be a PHP version issue. I notice some reports about this around the web.
Try Downgrading to another version of PHP.
Thanks for your reply. I’ll try it out and update the results.
I just installed 3.1.2 with Php 7.3 and it works 100%
I suspect something may have gone wrong with your install. Your logs would give us more of a clue. If you post some more info many of the others on the forum will also pitch in and try to help.
Try looking in Apache’s error.log for clues about what’s going on.
I did check the server logs - but there were no errors on the server logs. Only error was on Mautic logs as mentioned above. It was really weird, and I had a hard time trying to figure out the issue.
However, just before trying your suggestion to downgrade to another version of PHP - I ran the the same sendToContact test again - magically it worked. This leads me to believe that it might have had something to do with the cache (although I did clearing it by: rm -rf var/cache/* previously).
I will continue to test and see if the issue happens again.
@tmbosmov That’s great news. I’m happy to hear your install is going again.
Clearing the Cache is a great place to start and recommended as the first troubleshooting step in Mautic’s Troubleshooting guide.
The PHP error you got is linked to PHP versions. But your Mautic version is compatible with PHP7.3 according to the docs.
Post some more log entries if the issue persist.