1

I create few contacts forms in Magento for example I have Contact1.phtml / Contact2.phtml / Contact3.phtml is there any way to setup transnational email for each contact form?

Right now I use only one transactional email for all with if statement, But I see a lot of blank spaces where the field not exist and is very ugly. The email now is look like this:

enter image description here

Thank you

1

2 Answers 2

1

I'm glad to meet you with this issue because i was struggling with same issue just 4 months ago.

You created multiple contact forms separately right? Did you insert these contact forms to design folder and is it displayed on your front website? Then, it's time to specify transnational email on each contact form.

I think you might copy the original contact form to make another forms. And you have to copy all of Model files to make contact form. Let me have a look contact form. For instance, AAA is frontname. You can change it as what you want

First of all, you have to change an action link each contact form like this

<form action= "<?php echo $this->getUrl("AAA/index/post"); ?>" id="salesContactForm" method="post" class="scaffold-form">

app/code/local/YOURCOMPANY/AAA/controllers/IndexController.php

    public function postAction()
 +    {
 +        $post = $this->getRequest()->getPost();
 +        if ( $post ) {
 +            $translate = Mage::getSingleton('core/translate');
 +            /* @var $translate Mage_Core_Model_Translate */
 +            $translate->setTranslateInline(false);
 +            try {
 +                $postObject = new Varien_Object();
 +                $postObject->setData($post);
 +
 +                $error = false;
 +
 +                if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {
 +                    $error = true;
 +                }
 +
 +                if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) {
 +                    $error = true;
 +                }
 +
 +                if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
 +                    $error = true;
 +                }
 +
 +                if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
 +                    $error = true;
 +                }
 +
 +                if ($error) {
 +                    throw new Exception();
 +                }
 +                $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),
 +                        'YOUR_EMAIL_ADDRESS',
 +                       //Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
 +                        null,
 +                        array('data' => $postObject)
 +                    );
 +
 +                if (!$mailTemplate->getSentSuccess()) {
 +                    throw new Exception();
 +                }
 +
 +                $translate->setTranslateInline(true);
 +
 +                Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
 +                $this->_redirect('contacts');
 +
 +                return;
 +            } catch (Exception $e) {
 +                $translate->setTranslateInline(true);
 +
 +                Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
 +                $this->_redirect('contacts');
 +                return;
 +            }
 +
 +        } else {
 +            $this->_redirect('*/*/');
 +        }
 +    }

If you want to see full codes, please visit here https://github.com/meezin/Magento1.9_MultipleContactFormToDifferentRecipient/tree/master/app

And if you have any question, let me know and i want to see your codes tho

4
  • Hi thank you, can you tell me how I can change transactional email?
    – Robert
    Commented Jul 4, 2017 at 8:16
  • You can insert your transaction email to IndexController.php. Instead of Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), replace it 'EMAIL ADDRESS'
    – 3CE
    Commented Jul 5, 2017 at 12:42
  • hey did you test this? it obviously works!
    – 3CE
    Commented Jul 6, 2017 at 14:14
  • no because I don't understand very well, I don't need to change the email I need to change the template, that file where we change variables, for example /app/locale/en_US/template/email/contact_form.html
    – Robert
    Commented Jul 6, 2017 at 20:56
0

You can set theme in your config.xml module something like:

<global>
    ...
        <template>
            <email>
                <form_email_email_template translate="label" module="form">
                    <label>contact form</label>
                    <file>contact1.html</file><!--the name of email template,  PATH = app/locale/code_ISO/template/email/contact1.html-->
                    <type>text</type>
                </form_email_email_template>
            </email>
        </template>
    ...
</global>

EDIT:

If you haven't a module to do that and you want to create another contact form to send it for anther mail address, and maybe you want to customise it on adding the additional fields, you have to follow this inchoo tuto

15
  • Hi thank you for your answer, I don't use any module, can you tell me the exact path where I can put your code? Thank you again
    – Robert
    Commented Jul 4, 2017 at 8:16
  • Any module ?, you have well some code ?
    – PЯINCƎ
    Commented Jul 4, 2017 at 18:24
  • can be add in the magento default contact if I will add config.xml in the app/code/local ?
    – Robert
    Commented Jul 5, 2017 at 8:05
  • No, you can add the layout.xml of the module in local.xml, the config.xml no
    – PЯINCƎ
    Commented Jul 5, 2017 at 8:52
  • and if I want to add the second contact form? how will look the code?
    – Robert
    Commented Jul 5, 2017 at 8:58

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.