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.
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.
cron.sh
is running! We just spent a full day debugging this just to discover cron was misconfigured.
Commented
Jul 3, 2015 at 8:31
There are 2 methods to send mails from our Magento 1 store.
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
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;
}
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
With Magento 1.9 all the emails will be queued and later send through Cron.
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.
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:
After:
$isShellDisabled = (stripos(PHP_OS, ‘win’) === false) ? $isShellDisabled : true;
add this line of code:
$isShellDisabled = true;
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
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.
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.
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.
for godaddy server use following code while set up the cronjob:
* * * * * /usr/local/bin/php -q /home/steelwa/public_html/project_name/cron.php
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.
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.
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
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\*/) {
If you have extension SMTPpro than try to disable it. And check again. All emails work fine and you only need to configure correctly.
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