Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Order confirmation mail not sending in magento 1.9+ versions

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 1.30k
    Comment on it

    From magento 1.9+ versions , emails are not being sent directly , they were queued and queued mails were being processed by magento cronjob. You need to set the cron job correctly to send the mail.

    If you want to send mail forcefully after placing an order you need to do following changes -

    1) Copy Template.php from app/code/core/Mage/Core/Model/Email/ to app/code/local/Mage/Core/Model/Email/ folder .

    2) Edit Template.php file send() function. Comment the queue code i.e. code inside if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) { }

    Also to send email from admin sales->order send email button follow these steps -

    1) Copy Order.php from app/code/core/Mage/Sales/Model/ to app/code/local/Mage/Sales/Model/ folder.

    2) Edit sendNewOrderEmail() function in Order.php file. Update the function with the following code -

    public function sendNewOrderEmail()
        {
    
            if (!Mage::helper('sales')->canSendNewOrderEmail($this->getStore()->getId())) {
                return $this;
            }
    
         $translate = Mage::getSingleton('core/translate');
    
         $translate->setTranslateInline(false);
    
         $paymentBlock = Mage::helper('payment')->getInfoBlock($this->getPayment())
             ->setIsSecureMode(true);
    
         $paymentBlock->getMethod()->setStore($this->getStore()->getId());
    
         $mailTemplate = Mage::getModel('core/email_template');
    
         $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
         $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStoreId());
         if ($copyTo && $copyMethod == 'bcc') {
             foreach ($copyTo as $email) {
                 $mailTemplate->addBcc($email);
             }
         }
    
         if ($this->getCustomerIsGuest()) {
             $template = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStoreId());
             $customerName = $this->getBillingAddress()->getName();
         } else {
             $template = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $this->getStoreId());
             $customerName = $this->getCustomerName();
         }
    
         $sendTo = array(
             array(
                 'email' => $this->getCustomerEmail(),
                 'name'  => $customerName
             )
         );
         if ($copyTo && $copyMethod == 'copy') {
             foreach ($copyTo as $email) {
                 $sendTo[] = array(
                     'email' => $email,
                     'name'  => null
                 );
             }
         }
    
         foreach ($sendTo as $recipient) {
             $mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$this->getStoreId()))
                 ->sendTransactional(
                     $template,
                     Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $this->getStoreId()),
                     $recipient['email'],
                     $recipient['name'],
                     array(
                         'order'         => $this,
                         'billing'       => $this->getBillingAddress(),
                         'payment_html'  => $paymentBlock->toHtml(),
                     )
                 );
         }
         $this->setEmailSent(true);
         $this->_getResource()->saveAttribute($this, 'email_sent');
         $translate->setTranslateInline(true);
    
         return $this;
        }
    

    Now after updating the files mail were send right after placing an order.

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: