2

Email code:

public function getNotification() {

    return Mage::getStoreConfig('example/general/notification');
}

public function sendEmail() { 
$storeId = Mage::app()->getStore()->getId();
        $templateId = Mage::helper('example')->getNotification();
        $emailTemplate = Mage::getModel('core/email_template')->loadDefault($templateId);
        $senderMail = Mage::helper('example')->getEmailAddress();
        $senderName  = Mage::helper('example')->getName();
        $receiver = array(
                $senderMail => $senderName,
                $authorMail => $authorName
            );

        $emailTemplate->setTemplateSubject("New Notification Added For ". $productName);
        $emailTemplate->setSenderEmail($senderMail, $storeId);
        $emailTemplate->setSenderName($senderName, $storeId);
        $emailTemplate->send(array_keys($receiver),array_values($receiver), $post);
 }

my code in config.xml

<template>
            <email>
                <general_notification translate="label" module="example">
                    <label>Notifications</label>
                    <file>notification.html</file>
                    <type>html</type>
                </general_notification>

            </email>
        </template>

system.xml

<notification>
<label>Notification send to admin and customer</label>
    <frontend_type>select</frontend_type>


    <source_model>adminhtml/system_config_source_email_template</source_model>
        <sort_order>90</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>

</notification>

Now In System > Transaction Email I m add New template and save that template In config I m get template name but using this template my mail is send but Email is empty. there is no content display

2 Answers 2

1

I m just change my email method

const XML_PATH_EMAIL_CONTRACT_NOTIFICATION = 'example/general/notification';

 public function sendEmail() { 
 $translate = Mage::getSingleton('core/translate');
          $translate->setTranslateInline(false);
          $mailTemplate = Mage::getModel('core/email_template');
          $templateConfigPath = self::XML_PATH_EMAIL_CONTRACT_NOTIFICATION;
          $receiverMail= '[email protected]';
          $senderMail = Mage::helper('example')->getEmailAddress();
            $senderName  = Mage::helper('example')->getName();

          $sentFrom = array('email'=>$senderMail,'name'=>$senderName);
          $template = Mage::getStoreConfig($templateConfigPath, Mage::app()->getStore()->getId());
          $mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>Mage::app()->getStore()->getId()))
              ->($template,$sentFrom,$receiverMail,'admin',$post);
 }

This is work for me hope so this will help other

0

you can use load function for this like below

$this->_email_template = 'id of template' // int

 $emailTemplate = Mage::getModel('core/email_template')->load($this->_email_template);  

 $vars = array('ReviewURL' => $ReviewUrl,
                            'ProductName' => $productName,
                            'url' => $productUrl,
                            'ProductImage' => $productImage,
                            'couponcode'=>$couponCode);

                        $emailTemplate->getProcessedTemplate($vars);

                        $from = $this->getFromMail($this->_identity);
                        $emailTemplate->setSenderEmail($from['email']);

                        $emailTemplate->setSenderName($from['name']);
                        $billingAddress = $order->getBillingAddress();
                        $success_flag = $emailTemplate->send($order->getCustomerEmail(), $billingAddress->getFirstname(), $vars);

hope this will work for you

7
  • not working....
    – ND17
    Commented Apr 15, 2015 at 12:24
  • recheck your template path in config.xml
    – liyakat
    Commented Apr 15, 2015 at 12:25
  • which path i cant understand . i write code for email in above. is there any other code write in config.xml?
    – ND17
    Commented Apr 15, 2015 at 12:35
  • are you able to see your template name in admin ?
    – liyakat
    Commented Apr 15, 2015 at 12:48
  • In System > Transaction Email > New Email Template? if yes there is no template name
    – ND17
    Commented Apr 15, 2015 at 12:55

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.