New order email confirmation not being sent
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.
- 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.
Make sure `cron.sh` is running! We just spent a full day debugging this just to discover cron was misconfigured.
how to know whether cron.php is working or not?
You can trace the logs inside /var/log/cron
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 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.
There are 2 methods to send mails from our Magento 1 store.
- By Using cron
- 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
working perfectly, is that necessary to add code on success.phtml becoz without that it seems working fine
Hello Happy to listen this. No need to add any code because the transactional mail will reach to email immediately.
Never change (or overwrite, for that matter) vendor code - what happens when you upgrade?
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; }
This method solved the problem,but newsletter subscription is not working.Rolling back to old template.php solved the news letter subscription problem.
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
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
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.
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.
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 thecron.php
in serverThe
cron.php
file set thecore_email_queue_send_all
in cron schedule table. When crone execute the "send" method called fromMage_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.
License under CC-BY-SA with attribution
Content dated before 6/26/2020 9:53 AM
matinict 5 years ago
http://merch.docs.magento.com/ce/user_guide/Magento_Community_Edition_User_Guide.html#magento/release-notes-ce-1.9.1.html?Highlight=Queue