Pergunta

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

Foi útil?

Solução

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?

Outras dicas

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/

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)

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();
 }
 }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top