1

I am having problem to call template pankaj.html after sending mail. I have search through google but not found better solution to solve my issue.

path: /app/locale/en_US/template/email/pankaj.html

& i am calling template file in config.xml of module under global tag.

 <template>
            <email>
                <inquiry  module="inquiry">
                    <label>pankaj</label>
                    <file>pankaj.html</file>
                    <type>html</type>
                </inquiry>
            </email>
   </template>

Controller code:

 public function sendemailAction()
        {
            echo "abc";
            $data = $this->getRequest()->getParams();

            //echo "<pre>"; print_r($data); 

            $adminUserModel = Mage::getModel('admin/user');
            $admin = $adminUserModel->getCollection()->load();

            $emailTemplate = Mage::getModel('core/email_template')
                    ->loadDefault('inquiry');


            $senderName = $admin->getFirstItem()->getFirstname();
            $senderEmail = $admin->getFirstItem()->getEmail();  
        $sender = array('name' => $senderName,
            'email' => $senderEmail);


        $recepientEmail = array();
        $recepientName =array();

        /*$customer_name = $senderName = $customer->getFirstname().' '.$customer->getLastname();*/
        $recepientEmail = $data['email'];

        $store = Mage::app()->getStore()->getId();

        $vars = array('product_name' => $data['productname'],
            'sku' => $data['sku'],
            'qty' => $data['qty'],
            'customprice' => $data['customprice']
            );

        $translate  = Mage::getSingleton('core/translate');

        // Send Transactional Email

        try {


            Mage::getModel('core/email_template')
            ->sendTransactional($emailTemplate, $sender, $recepientEmail, $vars, $store);


            $translate->setTranslateInline(true);   


            Mage::getSingleton('core/session')->addSuccess('email send');

        }        
        catch(Exception $ex) {

            Mage::getSingleton('core/session')->addError('Unable to send email. Sample of a custom notification error.');

        }
        $this->_redirect('');
    }

To check pankaj.html file, i have print $text in template.php file. echo "<pre>"; print_r($text); die;

path: app/code/core/Mage/Core/Model/Email/template.php

How to solve this issue, Thanks in Advance .

1 Answer 1

1

Use following code to solve issue

$emailTemplate  = Mage::getModel('core/email_template')->loadDefault('inquiry');

I suggest you to following magento default contact us email

2
  • i have replace loadDefault('pankaj') to loadDefault('inquiry') but still i am having problem to call pankaj.html Dec 12, 2016 at 6:00
  • follow Magento Contact module it's best practice Dec 12, 2016 at 6:01

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.