I am using Custom order status While changing it send a mail. It's working fine

public function shipementorderAction(){
                $id = $this->getRequest()->getParam('id');

                $order = Mage::getModel('sales/order')->load($id);
                $order->setData('state', 'shipement');
                $history = $order->addStatusHistoryComment('', false);

                $order->sendOrderUpdateEmail(true, null);

                    $this->__('The order state has been changed.')
                Mage::getSingleton('core/session') ->addSuccess('Order Updated Successfully'); $this->_redirectReferer();


I used this to send a mail

**$order->sendOrderUpdateEmail(true, null);**

How to send custom email template(New Template) per status

2 Answers 2


You can use this method as starting point:


public function queueNewOrderEmail($forceMode = false)
    $storeId = $this->getStore()->getId();

    if (!Mage::helper('sales')->canSendNewOrderEmail($storeId)) {
        return $this;

    // Get the destination email addresses to send copies to
    $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
    $copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId);

    // Start store emulation process
    /** @var $appEmulation Mage_Core_Model_App_Emulation */
    $appEmulation = Mage::getSingleton('core/app_emulation');
    $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);

    try {
        // Retrieve specified view block from appropriate design package (depends on emulated store)
        $paymentBlock = Mage::helper('payment')->getInfoBlock($this->getPayment())
        $paymentBlockHtml = $paymentBlock->toHtml();
    } catch (Exception $exception) {
        // Stop store emulation process
        throw $exception;

    // Stop store emulation process

    // Retrieve corresponding email template id and customer name
    if ($this->getCustomerIsGuest()) {
        $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
        $customerName = $this->getBillingAddress()->getName();
    } else {
        $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
        $customerName = $this->getCustomerName();

    /** @var $mailer Mage_Core_Model_Email_Template_Mailer */
    $mailer = Mage::getModel('core/email_template_mailer');
    /** @var $emailInfo Mage_Core_Model_Email_Info */
    $emailInfo = Mage::getModel('core/email_info');
    $emailInfo->addTo($this->getCustomerEmail(), $customerName);
    if ($copyTo && $copyMethod == 'bcc') {
        // Add bcc to customer email
        foreach ($copyTo as $email) {

    // Email copies are sent as separated emails if their copy method is 'copy'
    if ($copyTo && $copyMethod == 'copy') {
        foreach ($copyTo as $email) {
            $emailInfo = Mage::getModel('core/email_info');

    // Set all required params and send emails
    $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
        'order'        => $this,
        'billing'      => $this->getBillingAddress(),
        'payment_html' => $paymentBlockHtml

    /** @var $emailQueue Mage_Core_Model_Email_Queue */
    $emailQueue = Mage::getModel('core/email_queue');


    $this->_getResource()->saveAttribute($this, 'email_sent');

    return $this;

Obviously you have to implement some methods to retrieve configuration like $storeId and $templateId that in the example are already there (since is declared inside the order model).

I think that the best approach could be hook the order status change and implement all the email send logic in a helper in order be reused in the future and even better split that method and abstract all the order logic, so you will have a good base to send any kind of emails.

I assume that you already know how to save and load configuration but i recommend you to use some method (like getEmailTemplateByStatus($status)) with a default return value to avoid errors just if someone add a custom status and it hasn't any template mapped.

Hope it help

  • @ MauroNigrele Hi, Do you know about html to magento conversion? Dec 26, 2015 at 11:57
  • @TejabhagavanKollepara sorry i don't catch your point Dec 26, 2015 at 11:59
  • Okay i'll tell you. Dec 26, 2015 at 12:00
  • i want to convert html to magento . I have html pages, from that i want to make magento website. I think you got .Please tell me Dec 26, 2015 at 12:00
  • 1
    The question you linked it's closed, anyway it's an biz question you can't just translform html files into magento you must create a theme declare layouts and edit templates to achieve it. sorry Dec 26, 2015 at 13:09

You have to use custom email send, see answer of this question


instead of

**$order->sendOrderUpdateEmail(true, null);**

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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