5

Is there an easy way to send the contact us to multiple recipients? javascript validation appears to limit to one email address.

3 Answers 3

1

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?

1
  • ya - exactly what I was thinking, just didn't know if there was another way that could easily be handled in magento.
    – veilig
    Commented Feb 19, 2013 at 1:18
1

Setting up a group email is the easy way.

Otherwise, you'd have to:

  1. Create a new JS validation rule (via Validation.add() in prototype/validation.js)
  2. Configure the field to use the new rule (recipient_email in Mage/Contacts/etc/system.xml)
  3. Update the way the value is handled once validated (postAction() in Mage/Contacts/controllers/IndexController.php)

Here you can find code to use in the controller action: http://www.magentocommerce.com/boards/viewthread/74568/

0

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();
 }
 }
2
  • 1
    The 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.
    – veilig
    Commented 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.