Ob_start not being called from cron

Hi all,
I have a script that runs each hour which loops through rows in a db and emails each row to the client. If I manually run the script the emails submit successfully with all the details in. If I want for the cron to run each hour the emails that get sent out are blank!!
The code in question is:

ob_start();
include $template;
$message .= ob_get_contents();
ob_end_clean();

The command line that runs each hour is:
/usr/bin/php54 /home/sites/#####.com/public_html/controllers/send-enquiries.php

(Ive hashed out the domain for security).

So why is the buffer being run if I manually run the script, but not if the scheduler runs it?

Any advice would be muchly appreciated as Im tearing my hair out over this!!! :slight_smile:
Thanks

no need to use include with output buffer. you can get the template’s content by file_get_contents(). if you need replacements in the template beyond the capabilities of str_replace() consider using a template engine (e.g. Twig).

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