Magento – Magento 1.9.2.1 Cron not working for Order confirmation emails

croncrontabmagento-1.9transactional-mail

I am experiencing very weird issues since this morning (up until then everything seemed to work fine). I made no changes to any code or settings.

All transactional emails are being sent (newsletter subscription, new customer confirmation etc), but not order confirmations. If I go to the backend and click "Send Email", nothing happens.

Exception and system logs are empty.

I have AOE Scheduler installed and it always says "no heartbeat task found". I configured cron as recommended by AOE:

* * * * * ! test -e /home/m1machining/public_html/maintenance.flag && /bin/bash /home/m1machining/public_html/scheduler_cron.sh --mode always
* * * * * ! test -e /home/m1machining/public_html/maintenance.flag && /bin/bash /home/m1machining/public_html/scheduler_cron.sh --mode default

Cron schedule table is not empty, shows that tasks were scheduled, but not executed.

If I "Run Now" with AOE, let's say scheduled emails task, in the database it shows that they've been executed, yet none of the emails being delivered.

If I truncate the cron schedule table, then it seems that it's not being repopulated.

What am I missing?

EDIT:

Fixed cron. AOE is working, all the tasks are displayed green, yet order confirmations still not sending. If I go to the backend and click on "Send Mail" for an order – nothing happens, in fact, it doesn't even being put in database email queue (not sure if it supposed to happen, but assume so).

Best Answer

Starting from Magento 1.9 the order confirmation emails are not sent during checkout anymore - instead, they are being sent with the Cron.

First, make sure your system Cron is up and running (you can check the Cron logs: /var/log/cron to verify that).

If system Cron is healthy, then you have to make sure Magento Cron is setup correctly and is running every some minute. You should see something like this in the Crontab of your system:

*/5 * * * * /public_html/cron.sh

This schedules a task to run cron.sh every five minutes. (More reading)

There are good extensions like AOE Scheduler in Magento that help you to monitor and manage Cron jobs.

An alternative way to this is to disable the Cron for these kinds of emails (order confirmation). To do this you can go to this path:

public_html/app/code/core/Mage/Sales/Model/Order.php

Copy that file and bring it to this path (if the path doesn't exist create it):

public_html/app/code/local/Mage/Sales/Model/Order.php

And then change this line:

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

To:

$mailer->send();

However, I recommend spending some time to set up the Cron instead. I think if they wanted to use Cron for these emails it's for a reason.

Related Topic