Is there an easy way to send the contact us to multiple recipients? javascript validation appears to limit to one email address.
3 Answers
I'd say the easiest solution would be to set up a proxy email address which will forward emails to the list of users.
It isn't what you was going to hear, eh?
-
ya - exactly what I was thinking, just didn't know if there was another way that could easily be handled in magento.– veiligCommented Feb 19, 2013 at 1:18
Setting up a group email is the easy way.
Otherwise, you'd have to:
- Create a new JS validation rule (via
Validation.add()
inprototype/validation.js
) - Configure the field to use the new rule (
recipient_email
inMage/Contacts/etc/system.xml
) - Update the way the value is handled once validated (
postAction()
inMage/Contacts/controllers/IndexController.php
)
Here you can find code to use in the controller action: http://www.magentocommerce.com/boards/viewthread/74568/
1) Go to System > Configuration > Contacts and add your Email-id’s in comma delimit in “Send Emails To” field (eg: [email protected],[email protected]@gmail.com)
Edit file code/core/Mage/Contacts/controllers/IndexController.php or make a 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();
}
}
-
1The Javascript validation won't even allow you to get to this point and I would steer clear of recommending anyone to modify core code, encourage them to create a module so they don't break their upgrade path.– veiligCommented Jan 3, 2014 at 13:21
-
@veilig If you want multiple recipients then obviously you're going to create a new module (needless to say). Also we can override JS validation using class="validate-emails" to allow multiple email id's. Commented Jan 3, 2014 at 13:24