Mautic is a free emailing software that can be even installed to your cPanel account using the ever-popular Softaculous.
With a single click, you are ready to go right? Wrong. You still need to setup the CronJobs which can sometimes be a real pain to do properly especially if your shared hosting provider has some limitations in doing so.
The simple solution is to initiate these CronJobs outside your cPanel / Plesk with a simple script.
1. Login your cPanel / Plesk and open File Manager.
2. Create new file into Mautic’s folder named cron.php (or whatever you want to call it).
3. Copy and paste the script below to the newly created file. Save and close.
<?php if (!isset($_GET['MauTiCcRons'])) { echo 'The secret phrase is wrong.'; die; } $link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $allowedTasks = array( 'cache:clear', 'mautic:leadlists:update', 'mautic:campaigns:update', 'mautic:campaigns:trigger', 'mautic:email:process', 'mautic:fetch:email', 'doctrine:migrations:migrate', 'doctrine:schema:update --dump-sql', 'doctrine:schema:update --force' ); if (!isset($_GET['task'])) { echo 'Specify what task to run. You can run these:'; foreach ($allowedTasks as $task) { $href = $link . '&task=' . urlencode($task); echo '<br><a href="' . $href . '">' . $href . '</a>'; } echo '<br><a href="https://www.mautic.org/docs/setup/index.html">Read more</a>'; echo '<br><b style="color:red">Please, backup your database before executing the doctrine commands!</b>'; die; } $task = urldecode($_GET['task']); if (!in_array($task, $allowedTasks)) { echo 'Task ' . $task . ' is not allowed.'; die; } $fullCommand = explode(' ', $task); $command = $fullCommand[0]; $argsCount = count($fullCommand) - 1; $args = array('console', $command); if ($argsCount) { for ($i = 1; $i <= $argsCount; $i++) { $args[] = $fullCommand[$i]; } } require_once __DIR__.'/app/bootstrap.php.cache'; require_once __DIR__.'/app/AppKernel.php'; use SymfonyBundleFrameworkBundleConsoleApplication; use SymfonyComponentConsoleInputArgvInput; use SymfonyComponentConsoleOutputBufferedOutput; defined('IN_MAUTIC_CONSOLE') or define('IN_MAUTIC_CONSOLE', 1); try { $input = new ArgvInput($args); $output = new BufferedOutput(); $kernel = new AppKernel('prod', false); $app = new Application($kernel); $app->setAutoExit(false); $result = $app->run($input, $output); echo "<pre>n".$output->fetch().'</pre>'; } catch (Exception $exception) { echo $exception->getMessage(); }
4. Go to yourdomain.com/cron.php?MauTiCcRons and keep this tab open.
5. Sign up at: https://cron-job.org/ .
6. Use the link at step 4. to create new ones and add them to the cron-job.org:
yourdomain.com/cron.php?&task=mautic%3Aleadlists%3Aupdate 1
yourdomain.com/cron.php?&task=mautic<campaigns%3Aupdate
yourdomain.com/cron.php?&task=mautic<campaigns%3Atrigger
yourdomain.com/cron.php?&task=mautic>mail%3Aprocess
Now Cronjobs will be run by cron-job.org via the php script above, so any Cronjob limitations your hosting provider might throw at you are bypassed.
How to know how to billd a link to execute a cron job