0
votes

I have created a custom module in magento named vendor Complaints. Here Vendor user can send a mail about his complaints to admin and admin can send a reply mail to that particular vendor user. So I have created 2 different mail templates, But I dont know how to send for both at a time.

Now I have completed sending reply email to vendor user, but I have not done sending mail to admin user.

My code for sending reply mail to vendor user:

       /**sending email*/
            $emailTemplate = Mage::getModel('core/email_template')->loadDefault('vendor_complaints_email_template');

            //Getting the Store E-Mail Sender Name.
            $senderName = Mage::getStoreConfig('trans_email/ident_general/name');

            //Getting the Store General E-Mail.
            $senderEmail = Mage::getStoreConfig('trans_email/ident_general/email');

            //Variables for Confirmation Mail.
            $emailTemplateVariables = array();
            $emailTemplateVariables['name'] = $customerName;
            $emailTemplateVariables['email'] = $customerEmail;              

            //Appending the Custom Variables to Template.
            $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);

            //Sending E-Mail to Customers.
            $mail = Mage::getModel('core/email')
                ->setToName($customerName)
                ->setToEmail($customerEmail)
                ->setBody($processedTemplate)
                ->setSubject('ShopU Store : Vendor Complaints')
                ->setFromEmail($senderEmail)
                ->setFromName($senderName)
                ->setType('html');

                //echo "<pre>";
                //print_r($mail);
                //die;

             try{
                    //Confimation E-Mail Send
                    $mail->send();
                 }
             catch(Exception $error)
             {
                Mage::getSingleton('core/session')->addError($error->getMessage());
                return false;
             }

            /**end**/

Can anyone tell me how to send mail to admin users also at a time???

Thanks in advance..

1

1 Answers

0
votes

You could consolidate this but something like:

//Sending E-Mail to Customers.
            $mail = Mage::getModel('core/email')
                ->setToName($customerName)
                ->setToEmail($customerEmail)
                ->setBody($processedTemplate)
                ->setSubject('ShopU Store : Vendor Complaints')
                ->setFromEmail($senderEmail)
                ->setFromName($senderName)
                ->setType('html');
             try{
                    //Confimation E-Mail Send
                    $mail->send();
                 }
             catch(Exception $error)
             {
                Mage::getSingleton('core/session')->addError($error->getMessage());
                return false;
             }

//Sending E-Mail to Admin.

        $emailTemplate = Mage::getModel('core/email_template')->loadDefault('vendor_complaints_email_temp‌​late_for_admin');
            $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
            $adminMail = Mage::getModel('core/email')
                ->setToName('Admin Name')
                ->setToEmail('[email protected]')
                ->setBody($processedTemplate)
                ->setSubject('ShopU Store : Vendor Complaints')
                ->setFromEmail($senderEmail)
                ->setFromName($senderName)
                ->setType('html');

             try{
                    //Confimation E-Mail Send
                    $adminMail->send();
                 }
             catch(Exception $error)
             {
                Mage::getSingleton('core/session')->addError($error->getMessage());
                return false;
             }