102

I have upgraded my website to 1.9.1 and now my customers are not receiving order confirmation email.

I tried sending through the admin panel but nothing happens, also no update email is being received.

1

16 Answers 16

95
  1. Starting with Magento 1.9.1 the emails are not being sent directly during checkout but instead are being queued.
  2. The queue is being processed via your Magento cronjob - please ensure this has been set up and is running correctly.
  3. The extension AOE_Scheduler can help you in confirming that your Magento cronjob has been configured correctly and is running.
6
  • 6
    Make sure cron.sh is running! We just spent a full day debugging this just to discover cron was misconfigured.
    – forsvunnet
    Commented Jul 3, 2015 at 8:31
  • 2
    how to know whether cron.php is working or not? Commented Dec 24, 2015 at 12:20
  • 2
    You can trace the logs inside /var/log/cron Commented Mar 26, 2017 at 4:42
  • I have issue with order email in Magento 2. Cron is also running but mail not sending. Most of cron tasks are missed in database table. How can i resolve it?
    – Magecode
    Commented Jul 11, 2019 at 4:56
  • @Magecode I'd suggest searching for Magento 2 specific questions first. If there are none feel free to add your own question with details on what you have found / ruled out so far. Commented Aug 21, 2019 at 2:56
32

There are 2 methods to send mails from our Magento 1 store.

  1. By Using cron
  2. By Avoiding cron

If you want to avoid cron :

Open your order.php file at

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

Line#1356,1450,

change

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

to:

$mailer-> send();

In app/design/frontend/base/default/template/checkout/success.phtml: add following line Top success page for sending mail direct

$order = Mage::getModel('sales/order');
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
$order->loadByIncrementId($incrementId);
try{ 
    $order->sendNewOrderEmail();
} catch (Exception $ex) { 
    echo "Email Not Sent..."; 
}
$customer = Mage::getSingleton('customer/session')->getCustomer();
$email = $customer->getEmail();
//End Email Sending
4
  • working perfectly, is that necessary to add code on success.phtml becoz without that it seems working fine Commented Oct 16, 2017 at 10:50
  • 3
    Hello Happy to listen this. No need to add any code because the transactional mail will reach to email immediately. Commented Oct 17, 2017 at 5:16
  • 1
    Never change (or overwrite, for that matter) vendor code - what happens when you upgrade?
    – Bachi
    Commented Oct 29, 2018 at 9:19
  • Thanks, for some reason cron had stopped working properly after a server update and rather than spending hours trying to work out how to fix that, I decided to just disable it. This fix worked perfectly. My store receives very few orders anyway so I don't see the point in queuing emails, better if they just get sent straight away. I agree that normally you shouldn't change vendor code, but Magento 1.9 will never be upgraded again, so in this case it's fine. Commented May 12, 2022 at 9:24
20

i removed the following mail queue code from Template.php , then i started receiving email when the order is placed by customer or when i click send email from the admin panel "Sales/Orders" tab.

Magento had set the order email to be sent by schedule job instead of instant email... probably for performance reason?(i dont know why, i am very new to magento)... however i am going to put this code back in the Template.php and find a way to set and run the schedule job to run every 5 minutes...

Template.php is located in => /app/code/core/Mage/Core/Model/Email/Template.php

   if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) { 

    /** @var $emailQueue Mage_Core_Model_Email_Queue */
        $emailQueue = $this->getQueue();
        $emailQueue->setMessageBody($text);
        $emailQueue->setMessageParameters(array(
                'subject'           => $subject,
                'return_path_email' => $returnPathEmail,
                'is_plain'          => $this->isPlain(),
                'from_email'        => $this->getSenderEmail(),
                'from_name'         => $this->getSenderName(),
                'reply_to'          => $this->getMail()->getReplyTo(),
                'return_to'         => $this->getMail()->getReturnPath(),
            ))
            ->addRecipients($emails, $names, Mage_Core_Model_Email_Queue::EMAIL_TYPE_TO)
            ->addRecipients($this->_bccEmails, array(), Mage_Core_Model_Email_Queue::EMAIL_TYPE_BCC);
        $emailQueue->addMessageToQueue();

        return true;
    }
1
  • This method solved the problem,but newsletter subscription is not working.Rolling back to old template.php solved the news letter subscription problem. Commented Sep 7, 2015 at 12:36
14

There two solution as follows:

Solution-01: Using cron

System > Configuration > Advanced > System > Cron

The default settings are:

First of all, Magento 1.9+ relies completely on cron jobs to send transactional emails. If you didn’t have cron jobs set up properly before, you are going to have to do it now.

First of all make sure you have set up cron tasks in the Magento admin under

System > Configuration > Advanced > System > Cron

The default settings are:

Generate Schedules Every 15 Schedule Ahead for 20 Missed if Not Run Within 15 History Cleanup Every 10 Success History Lifetime 60 Failure History Lifetime 600

There are people suggesting these settings should be changed, but since they can’t seem to agree on the best combination, I’d rather leave it as it is.

You then need to go into your hosting control panel and set up cron jobs. In cPanel it’s under Advanced > Cron Jobs. Set them up to run every five minutes and use this command:

php -f /home/username/public_html/cron.php

Check that the above path is correct and that the file cron.php is actually there in the root of your Magento installation (if you’ve just upgraded, it should be). Change username to the correct account.

Now, I initially made the mistake of following the advice of the developers at xtento.com who say to use a wget command string: wget -O /dev/null -q http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php

Solution-02:Avoid cron

Transactional emails will be sent instantly.

//app/code/core/Mage/Sales/Model/Order.php Line#1356,1450 
  //$mailer->setQueue($emailQueue)->send(); Change To 

          $mailer->send();

app/design/frontend/base/default/template/checkout/success.phtml
    //add following line Top success page for sending mail direct
    // Start Send Emai Here......
    $order = Mage::getModel('sales/order');
    $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
    $order->loadByIncrementId($incrementId);

    try{ $order->sendNewOrderEmail();} 
    catch (Exception $ex) { echo "Email Not Sent..."; }
    $customer = Mage::getSingleton('customer/session')->getCustomer();
    $email = $customer->getEmail();//End Email Sending
0
10

With Magento 1.9 all the emails will be queued and later send through Cron.

Magento 1.9 Release Note

If you want your Transaction Emails to be sent through Cron, you can set the cron from from System>Configuration>System under tab Cron OR create cron in Cpanel direct it to your cron.sh or cron.php located in your root Magento directory.

10

Just install the "SMTP Pro Email" extension: http://www.magentocommerce.com/magento-connect/smtp-pro-email-free-custom-smtp-email.html

Fill in with your Custom SMTP details and done.


This took me two full days to figure out. No Cron Jobs needed, although if you do want cron jobs working and you don't want to do the above, you can do the following:

Edit cron.php in Magento root directory

After:

$isShellDisabled = (stripos(PHP_OS, ‘win’) === false) ? $isShellDisabled : true;

add this line of code:

$isShellDisabled = true;

Set up Cron Job

On C Panel open Cron Jobs section
Create a cron job that runs the following command every 15 minutes:

php -f /home/USERNAME/public_html/domain.com/magento_folder/cron.php
1
  • Important to note that with SMTP Pro this configuration must be done for Magento 1.9.1 and above : System -> Configuration -> SMTP Pro -> Queue Configuration -> Queue Usage change from Default to Never.
    – Shrenik
    Commented Jun 10, 2017 at 5:55
8

In Magento 1.9.1.0, Magento has added a new feature: They store the order email in the core_email_queue table to send the email of orders. We have to set the cron.php in server

The cron.php file set the core_email_queue_send_all in cron schedule table. When crone execute the "send" method called from Mage_Core_Model_Email_Queue. They send the mail to customer.

So above fix is working without any change in core file.

7

Using n98-magerun I just run the following:

n98-magerun sys:cron:run core_email_queue_send_all

Or to time it if you don't want to run it all the time:

watch -n 10 n98-magerun sys:cron:run core_email_queue_send_all

This sends all the emails in queue every 10 seconds.

6

Just do the cron setup on your server as below command & then you will start receiving sales mails.

php -q /home/YOUR_USER_NAME/public_html/Path_to_cron.php

Use common settings as " ***** "

Need to replace YOUR_USER_NAME & Path_to_cron.php with yours.

6

for godaddy server use following code while set up the cronjob:

*   *   *   *   *   /usr/local/bin/php -q /home/steelwa/public_html/project_name/cron.php

This will run every minute.enter image description here

5

if it is ONLY the order email not sending, it is because Magento queues only the order emails and saves them to send them out in batches. If you don't have your Heartbeat Cron setup.. then they will never leave the Magento queue.

You're seeing other Magento emails go out because those are handed directly from Magento to your mailer daemon. The ones Magento queues (like the order email) aren't even handed to the mailer daemon until the Hearbeat Cron runs.

To force them to go out... navigate to http://yourmagentodomain.com/cron.php and keep refreshing that page every five minutes and you'll see the queued order emails start to go out. The Heartbeat Cron is supposed to do this for you. Oh, and when you navigate to that cron.php file, the page is supposed to be blank so don't be alarmed... it will work.

5

I had the same issue and found out that it was related to an extension. Fooman Email Attachments has now been updated to v0.10.4. Versions below v0.10.3 won't work with Magento 1.9.

5

I followed the knowledge base to get it working: http://www.magentocommerce.com/knowledge-base/entry/ee1141-ce191-responsive-email#contact-info

In the part "Localizing Transactional Emails",after following the previous instructions, copying to /en_UK finally got the emails on their way (including ones previously not sent), We also had a problem with the order confirmation page not being displayed to customers on completion. This was fixed also.

For example for the en_GB locale you would need to copy the files that are located at:

app/locale/en_US/template/email

to the location:

app/locale/en_GB/template/email

1
  • 2
    Welcome to Magento SE! Can you elaborate even further on your answer (offering code examples etc.)?
    – benmarks
    Commented Dec 11, 2014 at 4:18
3

If your mail system(smtp, zend_mail) works fine; disabling mailQueue may solve your problem.

/app/code/core/Mage/Core/Model/Email/Template.php

Change Line 407

if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {

to

if (false /\*$this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue\*/) {
3
  • 5
    this breaks the contact form functionality.
    – Zoya
    Commented Feb 12, 2015 at 17:37
  • 9
    Don't edit core Commented Aug 2, 2015 at 1:54
  • 1
    Please do not provide solutions that require changes to CORE. Core classes must never be changed. Commented Sep 14, 2016 at 10:09
2

If you have extension SMTPpro than try to disable it. And check again. All emails work fine and you only need to configure correctly.

0

Better way is make a copy of your app/code/core/Mage/Core/Model/Email/Template/Mailer.php

To your local folder app/code/local/Mage/Core/Model/Email/Template/Mailer.php

Then comment out this line in line 76

->setQueue($this->getQueue())

Then you're done. No need to modify the success.phtml template. :D

Not the answer you're looking for? Browse other questions tagged or ask your own question.