【问题标题】:How to Send to 2 different email to 2 different users at a time in magento?如何在magento中一次向2个不同的用户发送2个不同的电子邮件?
【发布时间】:2015-09-23 13:00:10
【问题描述】:

我在 magento 中创建了一个名为 vendor Complaints 的自定义模块。在这里,供应商用户可以向管理员发送关于他的投诉的邮件,管理员可以向该特定供应商用户发送回复邮件。所以我创建了 2 个不同的邮件模板,但我不知道如何同时发送。

现在我已经完成向供应商用户发送回复电子邮件,但我还没有完成向管理员用户发送邮件。

我向供应商用户发送回复邮件的代码:

       /**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**/

谁能告诉我如何同时向管理员用户发送邮件???

提前谢谢..

【问题讨论】:

    标签: php email magento


    【解决方案1】:

    您可以合并它,但类似:

    //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('admin@something.com')
                    ->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;
                 }
    

    【讨论】:

    • 这行得通吗?我认为它只会向客户发送邮件。
    • 我会尽力让你知道的。
    • 它应该可以正常工作。否则只需将第二个 $mail 换成 $adminMail
    • like $emailTemplate = Mage::getModel('core/email_template')->loadDefault('vendor_complaints_email_template');
    • $emailTemplate = Mage::getModel('core/email_template')->loadDefault('vendor_complaints_email_template_for_admin');
    猜你喜欢
    • 2017-02-05
    • 1970-01-01
    • 2013-01-21
    • 1970-01-01
    • 2012-12-04
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 2019-10-29
    相关资源
    最近更新 更多