Campaign Emails not sent: Fixed, Parse Error line 136, php for cron job

So I had a frustrating time getting this to all work, but here is what I did if it helps anyone.



My test emails would send, but my campaign emails would not. I tried Cronfig and still no dice.



To find out the error I went to my cron jobs page in cpanel, above the Add new cron job there is an option to Add Email so I get an email telling my if and how the cron job ran or if it had an error. (make sure to update/remove your email after you figure it all out or your inbox gets flooded with these updates).



Here is the error I got:



Parse error: syntax error, unexpected ‘$result’ (T_VARIABLE) in /home4/username/public_html/domain.com/m/plugins/MauticCitrixBundle/Helper/CitrixHelper.php on line 136



In reading online, it seems that this is not a CitrixHelper.php issue, but rather, a PHP VERSION ERROR. Just as we need 5.6 or better with Mautic, if your server runs cron jobs on the server’s default php of 5.4, then the discrepancy make the problem.



It turns out that even though I updated my php to 7.0 in cpanel, you have to update the php that the cron job is using. Basically I changed my cron job from this:



php-cli /home4/username/public_html/domain.com/m/app/console mautic:campaigns:trigger



to this:



/opt/php70/bin/php /home4/username/public_html/domain.com/m/app/console mautic:campaigns:trigger



in order to make sure my cron was using the same php version as everything else and viola! Success!


So I had a frustrating time getting this to all work, but here is what I did if it helps anyone.

My test emails would send, but my campaign emails would not. I tried Cronfig and still no dice.

To find out the error I went to my cron jobs page in cpanel, above the Add new cron job there is an option to Add Email so I get an email telling my if and how the cron job ran or if it had an error. (make sure to update/remove your email after you figure it all out or your inbox gets flooded with these updates).

Here is the error I got:

Parse error: syntax error, unexpected ‘$result’ (T_VARIABLE) in /home4/username/public_html/domain.com/m/plugins/MauticCitrixBundle/Helper/CitrixHelper.php on line 136

In reading online, it seems that this is not a CitrixHelper.php issue, but rather, a PHP VERSION ERROR. Just as we need 5.6 or better with Mautic, if your server runs cron jobs on the server’s default php of 5.4, then the discrepancy make the problem.

It turns out that even though I updated my php to 7.0 in cpanel, you have to update the php that the cron job is using. Basically I changed my cron job from this:

php-cli /home4/username/public_html/domain.com/m/app/console mautic:campaigns:trigger

to this:

/opt/php70/bin/php /home4/username/public_html/domain.com/m/app/console mautic:campaigns:trigger

in order to make sure my cron was using the same php version as everything else and viola! Success!

UPDATE: all my sites on shared hosting crashed on php7.0 as it is “unstable”

Back to finding a solution - cronfig sort of works, but only every 30 min and initial emails for campaigns not consistently going out… would welcome any other options

@alainarae I have the same issue now, how did you fix it, please help!

@boyan
Sorry for the delay - just saw this. I have it working - but don’t remember everything I did… I believe I reinstalled directly into my site. Here are my cron jobs if that helps: (I installed into folder “m” instead of “mautic” because I did not want to type the whole word everytime I went to work on it - I am lazy

36,40 * * * * /opt/php56/bin/php /home4/username/public_html/domain.com/m/app/console mautic:segments:update
5,20,35,50 * * * * /opt/php56/bin/php /home4/username/public_html/domain.com/m/app/console mautic:campaigns:update
*/22 * * * * /opt/php56/bin/php /home4/username/public_html/domain.com/m/app/console mautic:campaigns:trigger

My PHP is set back to 5.6

Probably not super helpful, but just in case