要在联系我们 Magento 中向多个收件人发送电子邮件,您可以通过这种方式进行托盘发送。
第一步,你可以在 app/code/core/Mage/Contacts/Controllers/IndexController.php 找到这一行
$mailTemplate = Mage::getModel('core/email_template');
/* @var $mailTemplate Mage_Core_Model_Email_Template */
$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)
);
并修改为:
$recipients = Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT);
if ($recipients)
{
$recipients = explode(";",$recipients);
if(count($recipients))
{
foreach($recipients as $recipient) {
$mailTemplate = Mage::getModel('core/email_template');
/* @var $mailTemplate Mage_Core_Model_Email_Template */
$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();
}
}
}
}
并且不要忘记在 app/code/core/Mage/Contacts/etc/system.xml 上评论验证 javascript
找到这一行:
<recipient_email translate="label">
<label>Send Emails To</label>
<frontend_type>text</frontend_type>
<!--<validate>validate-email</validate>-->
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</recipient_email>
对此行发表评论<validate>validate-email</validate>
此代码适用于 magento 1.7.0.2 中的我。我希望这对您的问题有所帮助.. :D
不要忘记保存和清除缓存..