Question

I'm using Magento's new 1.9.1 theme and I found that the order emails were not send. I found out this was caused because in the new edition you need to schedule a cron to send the mails.

This cron.php was already present in the root

// Change current directory to the directory of current script
chdir(dirname(__FILE__));

require 'app/Mage.php';

if (!Mage::isInstalled()) {
    echo "Application is not installed yet, please complete install wizard first.";
    exit;
}

// Only for urls
// Don't remove this
$_SERVER['SCRIPT_NAME'] = str_replace(basename(__FILE__), 'index.php',     
$_SERVER['SCRIPT_NAME']);
$_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php',    
$_SERVER['SCRIPT_FILENAME']);

Mage::app('admin')->setUseSessionInUrl(false);

umask(0);

$disabledFuncs = explode(',', ini_get('disable_functions'));
$isShellDisabled = is_array($disabledFuncs) ? in_array('shell_exec',   
$disabledFuncs) : true;
$isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;

try {
    if (stripos(PHP_OS, 'win') === false) {
        $options = getopt('m::');
        if (isset($options['m'])) {
            if ($options['m'] == 'always') {
                $cronMode = 'always';
            } elseif ($options['m'] == 'default') {
                $cronMode = 'default';
            } else {
                Mage::throwException('Unrecognized cron mode was defined');
         }
     } else if (!$isShellDisabled) {
        $fileName = basename(__FILE__);
        $baseDir = dirname(__FILE__);
        shell_exec("/bin/sh $baseDir/cron.sh $fileName -mdefault 1 > /dev/null 2>&1 &");
        shell_exec("/bin/sh $baseDir/cron.sh $fileName -malways 1 > /dev/null 2>&1 &");
        exit;
    }
}

    Mage::getConfig()->init()->loadEventObservers('crontab');
    Mage::app()->addEventArea('crontab');

    if ($isShellDisabled) {
        Mage::dispatchEvent('always');
        Mage::dispatchEvent('default');
    } else {
        Mage::dispatchEvent($cronMode);
    }
} catch (Exception $e) {
    Mage::printException($e);
    exit(1);
}

I've done some research on Google, and as far as I can understand only the following line has to be added

*/5 * * * * wget -O /dev/null -q http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php > /dev/null

Does this line need to be added to cron.php? And is that all it takes to send the emails?

Was it helpful?

Solution

THIS DEACTIVATES THE QUEUE COMPLETELY, but solves the issue!

I have met with this issue before. to solve

  1. copy file in app\code\core\Mage\Sales\Model\order.php to app\code\local\Mage\Sales\Model\order.php

  2. open in an editor

  3. Find this code

    $mailer->setQueue($emailQueue)->send();

replace it with $mailer->send(); and save.

  1. also make sure, you have added emails in sales email tab in system => configuration.

Good luck. Let me know if the problem solved.

OTHER TIPS

The line in question needs to be added to your cron scheduler. Using SSH you should be able to use crontab -e and it will prompt you to select your appropriate editor and insert the line at the end of the file.

Alternatively on servers with some kind of control panel (cPanel, Plesk etc) you may have an option to put it in via the management tool for those applications using the same format, or alternatively by putting the command in (wget -O /dev/null -q http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php) and setting the time intervals which should match the first element.

If you have server access, I would reccomend using cron.sh rather than the cron.php as this allows you to run complex tasks under cron without impacting on load on the web server process.

To use this you would set it up like the following:

*/5 * * * * php /path/to/magento/website/cron.sh

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top