Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6367691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:34:52+00:00 2026-05-25T00:34:52+00:00

I am sending order email by calling the method sendNewOrderEmail(); But email only goes

  • 0

I am sending order email by calling the method sendNewOrderEmail();
But email only goes with the Subject of the mail. No message is in there 🙁
What wrong am I making?

//http:/pragneshkaria.com/2011/08/11/genearate-order-programatically-magento-along-with-sales-quotes-sales-items-and-sales-address/
//http:/www.magentocommerce.com/boards/viewthread/28426/P45/
//require_once 'app/Mage.php';
require_once '../../../../../../../../../../app/Mage.php';
//$app = Mage::app('default');
$app = Mage::init(); // 1.5+ 
include('customer.php');

Mage::register('isSecureArea', true); //no output before here, will get a session header error




$customer_id = $customer->getId(); //222 rmuthe

$shopping_cart = array();


$part = array(
    array("PartId" => '1', "Quantity" => '1'),
    array("PartId" => '2', "Quantity" => '1')
);

$shopping_cart = $part; //repeat as necessary

//print_r($shopping_cart);

$params = array("AccountNo" => $customer_id, "PartCart" => $shopping_cart);
$quote_pk = PrepareOrder($params);
$order_pk = ConfirmOrder($quote_pk);

echo "<br />Quote Id Generated : " . $quote_pk;
echo "<br />Order Id Generated : " . $order_pk;

echo "<br />DONE";

function PrepareOrder($params) {
    foreach ($params as $k => $v){
        $$k = $v;
    }
    $customerObj = Mage::getModel('customer/customer')->load($AccountNo);
    $storeId = $customerObj->getStoreId();
    $quoteObj = Mage::getModel('sales/quote')->assignCustomer($customerObj); //sets ship/bill address
    $storeObj = $quoteObj->getStore()->load($storeId);
    $quoteObj->setStore($storeObj);
    $productModel = Mage::getModel('catalog/product');
    
    foreach ($PartCart as $part) {
        foreach ($part as $k => $v) {
            $$k = $v;
        }
        $productObj = $productModel->load($PartId);
        
        //Modified Here annet-pk
        //$quoteItem = Mage::getModel('sales/quote_item')->setProduct($productObj);
        try{
            $quoteItem = Mage::getModel('sales/quote_item')->setProduct($productObj);
        } catch (Exception $e){
            echo $e;
        }
        $quoteItem->setQuote($quoteObj);
        $quoteItem->setQty($Quantity);
        $quoteObj->addItem($quoteItem);
    }
    
    /*
    $quoteObj->collectTotals();
    $quoteObj->save();
    */
    $shippingMethod = 'flatrate_flatrate';
    $quoteObj->getShippingAddress()->setShippingMethod($shippingMethod);
    $quoteObj->getShippingAddress()->setCollectShippingRates(true);
    $quoteObj->getShippingAddress()->collectShippingRates();
    $quoteObj->collectTotals();//calls $address->collectTotals();
    $quoteObj->save();
    
    $quoteId = $quoteObj->getId();
    return $quoteId;
}

function ConfirmOrder($quoteId) {
/*
    $hpc_connector_orderid = '786-2222222-3333333';
    $hpc_connector_sitename = 'ebay'; //ebay / amazon
*/  
    //methods: authorizenet, paypal_express, googlecheckout, purchaseorder
    $hpc_payment_method = 'checkmo';
    
    //methods: flatrate_flatrate, freeshipping_freeshipping
    $hpc_shipping_method = 'flatrate_flatrate';
    $hpc_shipping_method_description = 'Here will be the links of the incoming items from the customer';

    $quoteObj = Mage::getModel('sales/quote')->load($quoteId);
    $items = $quoteObj->getAllItems();
    $quoteObj->collectTotals();
    $quoteObj->reserveOrderId();
    
    $quotePaymentObj = $quoteObj->getPayment();
    //methods: authorizenet, paypal_express, googlecheckout, purchaseorder
    $quotePaymentObj->setMethod($hpc_payment_method);
    
    $quoteObj->setPayment($quotePaymentObj);
    $convertQuoteObj = Mage::getSingleton('sales/convert_quote');
    
    $orderObj = $convertQuoteObj->addressToOrder($quoteObj->getShippingAddress());
    
    $orderPaymentObj = $convertQuoteObj->paymentToOrderPayment($quotePaymentObj);
    
    $orderObj->setBillingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getBillingAddress()));
    
    //annet -pk to set shipping method
    // $orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getShippingAddress()));
    $orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($quoteObj->getShippingAddress()))
    ->setShipping_method($hpc_shipping_method)
    ->setShippingDescription($hpc_shipping_method_description);
    
    $orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($quoteObj->getPayment()));
    /*
    $orderObj->setHpcOrderId($hpc_connector_orderid);
    $orderObj->setHpcOrderFrom($hpc_connector_sitename);
    */
    foreach ($items as $item) {
        //@var $item Mage_Sales_Model_Quote_Item
        $orderItem = $convertQuoteObj->itemToOrderItem($item);
        if ($item->getParentItem()) {
            $orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
        }
        $orderObj->addItem($orderItem);
    }
    $orderObj->setCanShipPartiallyItem(false);
    
    $totalDue = $orderObj->getTotalDue();
    
    //$orderObj->sendNewOrderEmail();
    
    $orderObj->place(); //calls _placePayment
    $orderObj->save();
    
    // $orderId = $orderObj->getId();
    // return $orderId;
    
    $orderObj->load(Mage::getSingleton('sales/order')->getLastOrderId());
    $lastOrderId = $orderObj->getIncrementId();
    echo "Recent Order Id :".$lastOrderId;
    
    
    
    
    
    /***************EMAIL*****************/
    $orderObj->loadByIncrementId($lastOrderId);

    try{
        echo "Trying to send an  mail";
        $emailed = $orderObj->sendNewOrderEmail();
    }catch (Exception $ex){
        echo "Failed to send a confirmation mail";
    }
    /***************EMAIL*****************/
    
    


    return $lastOrderId;
    
    
    
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:34:53+00:00Added an answer on May 25, 2026 at 12:34 am

    I have found my problem. It was in Magento1.5.1.0. in this version there was a problem in sending confirmation mail of order from the backend. Whenever i tries to send mail it through error. Thats why i commented two lines of code which through error. Those lines were about getting translation of order contents. Thats why it was failed to send a complete order confirmation mail. Later i degraded the magento version to 1.4.2.0. Now it works fine with the same code only i need to change one line like below:

    $app = Mage::app();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sending mail along with embedded image using asp.net I have already used following but
I'm having an issue with sending an order e-mail from Drupal (Ubercart). I actually
I need some help with sending email when an order is placed. To illustrate
Im sending out an order conformation for recipients via the simple mail function built
I've got a problem with email sending in cake. My method looks like this:
After user places an order I have to send detailed email message containing order
I'm using a script to create an email message, but for some reason, it
I'm using a mail function which is sending back a message that is contained
sending text to label and number to int from tabelview to viewcontroller but it
Sending Email in Android using JavaMail API without using the default/built-in app I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.