Friday 9 June 2017

Test email in order email notification in magento

Add following function into any frontend controller and check via URL

public function sendtestAction()
    {
        $order = Mage::getModel('sales/order');
        $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
        $order->loadByIncrementId($incrementId);
        echo $incrementId;
        try {
            echo $order->sendNewOrderEmail();
        } catch (Exception $ex) {
            echo "Email Not Sent...";
        }
        $customer = Mage::getSingleton('customer/session')->getCustomer();
        $email = $customer->getEmail(); //End Email Sending
        echo '<pre>Done';
        echo $email;exit;
    }