简体   繁体   中英

In magento how to add multiple recipients to 'Send Emails to' field in Email Options under contact Us

在我的magento网站中,我需要将联系电子邮件发送给多个收件人。如何在“电子邮件选项”的“ 发送电子邮件”字段中添加其他电子邮件ID。

1) Go to System > Configuration > Contacts and add your Email-id's in comma delimit in “Send Emails To” field (eg: test@gmail.com,user1@gmail.com.user2@gmail.com)

Copy file from code/core/Mage/Contacts/controllers/IndexController.php into your local like code/local/Mage/Contacts/controllers/IndexController.php or make your Custom Module depending upon your requirement.

In postAction you should find a few lines of code that look like this:

$mailTemplate->setDesignConfig(array('area' => 'frontend'))
 ->setReplyTo($post['email'])
 ->sendTransactional(
 Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
 Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
 Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
 null,
 array('data' => $postObject)
 );

if (!$mailTemplate->getSentSuccess()) {
 throw new Exception();
 }

Change it to below:

$recipients = explode(",",Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT));
 foreach($recipients as $recipient){
 $mailTemplate->setDesignConfig(array('area' => 'frontend'))
 ->setReplyTo($post['email'])
 ->sendTransactional(
 Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
 Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
 $recipient,
 null,
 array('data' => $postObject)
 );

 if (!$mailTemplate->getSentSuccess()) {
 throw new Exception();
 }
 }

没有办法通过magento的admin部分来实现它,如果它是你的强制要求,那么你需要覆盖magento联系人模块进行自定义。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM