New order email confirmation not being sent

79

28

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. Can any one help us with this problem for Magento 1.9.1?

user16826

Posted 2014-11-27T07:09:22.413

Reputation: 399

Answers

80

Starting with Magento 1.9.1 the emails are not being sent directly during checkout but instead are being queued. The queue is being processed via your Magento cronjob - please ensure this has been set up and is running correctly.

The extension AOE_Scheduler can help you in confirming that your Magento cronjob has been configured correctly and is running.

Kristof at Fooman

Posted 2014-11-27T07:09:22.413

Reputation: 9 528

2how to know whether cron.php is working or not? – Teja bhagavan Kollepara – 2015-12-24T12:20:32.587

2You can trace the logs inside /var/log/cron – Beto Castillo – 2017-03-26T04:42:16.997

5Make sure cron.sh is running! We just spent a full day debugging this just to discover cron was misconfigured. – forsvunnet – 2015-07-03T08:31:03.703

18

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;
    }

Helmey Hussain

Posted 2014-11-27T07:09:22.413

Reputation: 193

This method solved the problem,but newsletter subscription is not working.Rolling back to old template.php solved the news letter subscription problem. – balajisoundar – 2015-09-07T12:36:54.677

17

There are 2 methods to send mails from our magento store.

  1. Using cron
  2. Avoid 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

Teja bhagavan Kollepara

Posted 2014-11-27T07:09:22.413

Reputation: 2 029

working perfectly, is that necessary to add code on success.phtml becoz without that it seems working fine – Suneth Kalhara – 2017-10-16T10:50:14.277

2Hello Happy to listen this. No need to add any code because the transactional mail will reach to email immediately. – Teja bhagavan Kollepara – 2017-10-17T05:16:38.230

12

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

matinict

Posted 2014-11-27T07:09:22.413

Reputation: 597

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.

Ajay Bisht

Posted 2014-11-27T07:09:22.413

Reputation: 464

9

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

Jagoman

Posted 2014-11-27T07:09:22.413

Reputation: 106

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 – 2017-06-10T05:55:56.510

7

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.

Ankita Pancholi

Posted 2014-11-27T07:09:22.413

Reputation: 71

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.

Akhil Gupta

Posted 2014-11-27T07:09:22.413

Reputation: 1 369

5

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.

Timon de Groot

Posted 2014-11-27T07:09:22.413

Reputation: 563

5

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

alok

Posted 2014-11-27T07:09:22.413

Reputation: 191

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

Uncle_Paul

Posted 2014-11-27T07:09:22.413

Reputation: 51

2Welcome to Magento SE! Can you elaborate even further on your answer (offering code examples etc.)? – benmarks – 2014-12-11T04:18:32.627

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.

Aidan

Posted 2014-11-27T07:09:22.413

Reputation: 51

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.

loeffel

Posted 2014-11-27T07:09:22.413

Reputation: 471

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\*/) {

user20329

Posted 2014-11-27T07:09:22.413

Reputation: 63

7Don't edit core – Kevin Schroeder – 2015-08-02T01:54:14.717

1Please do not provide solutions that require changes to CORE. Core classes must never be changed. – Muhammad Ahsan Horani – 2016-09-14T10:09:03.230

4this breaks the contact form functionality. – Haya – 2015-02-12T17:37:06.740

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.

Developer Webile

Posted 2014-11-27T07:09:22.413

Reputation: 94