cancel
Showing results for 
Search instead for 
Did you mean: 

E-mail form that sends to different adress depending on choice in dropdown?

E-mail form that sends to different adress depending on choice in dropdown?

Hi all,

 

I would like a simple contact form with Name, E-mail, Comment and a drop down where user selects a value (like Clothing / Decoration / Kitchen). Depending on the choice in that drop down menu, I would like the feedback e-mail to be sent to two adresses, one general and one specific for the choice in question.

 

Example:

User selects "Clothing" -> E-mail gets sent to info@domain.com and clothing@domain.com

User selects "Decoration" -> E-mail gets sent to info@domain.com and decoration@domain.com

 

Anyone know of a Magento extension for this (for Magento Enterprise), or perhaps some external service that could allow us to do this?

 

Any help very appreciated!

1 REPLY 1

Re: E-mail form that sends to different adress depending on choice in dropdown?

An extension might be overkill for the simpe logic that you're after... creating your own extension wouldn't be too much work..

 

You'd have to

  • Create your module
  • Overwrite the the contact form in your theme and add the form field.
  • Overwrite the app/code/core/Mage/Contacts/IndexController.php - more specifically the postAction
  • Add some code in there to change email address depending on drop-down value... e.g.
    $email = 'default@yoursite.com';
    switch($post['yournewfield']) {
       case 'clothing':
          $email = 'clothing@yoursite.com';
       break;
    
       case 'decoration':
           $email = 'decoration@yoursite.com';
       break;
    }
    
    
  • Then where the function sends the email.. you'll need to use your email address instead:
                    $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                        ->setReplyTo($post['email'])
                        ->sendTransactional(
                            Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
                            Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
                            $email,
                            null,
                            array('data' => $postObject)
                        );
 

If you wanted to control the email addresses per department in the magento admin; then it's a little more work.. but the above should give you a foot-hold.

Problem solved? Click Accept as Solution!
Magento Certified Developer Plus | www.iwebsolutions.co.uk | Magento Small Business Partner