0

when i am submitting contact us form then only admin able to receive contact us email but customer not receive email who submit form after form submit why? please reply.

following is my form.phtml file

<div id="messages_product_view"><?php echo   $this->getMessagesBlock()->getGroupedHtml() ?></div>

<div class="row box-1-contact">
<div class="col-md-12 page-title title-c">
    <h1><?php echo $this->__('Contact Us');?></h1>
</div>
<?php if($this->getLayout()->createBlock('cms/block')->setBlockId('google-map')->toHtml()) { ?>
<div class="contact-map-wrap col-lg-6 col-md-6 col-sm-6 col-xs-12">
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('google-map')->toHtml() ?>
</div>
<?php } ?>
<form class="contact-form col-lg-6 col-md-6 col-sm-6 col-xs-12" action="<?php echo Mage::getUrl(); ?>contacts/index/post/" id="contactForm" method="post">
    <div class="form-wrapper">
        <ul class="form-list">
            <li class="fields">
                <div class="field">
                    <div class="input-box">
                    <div class="input-group">
 <span class="input-group-addon" id="basic-addon1"><i class="icon-user" aria-hidden="true"></i>
</span>
                        <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Your name') ?>" onfocus="if(this.value=='<?php echo Mage::helper('contacts')->__('Your name...') ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo Mage::helper('contacts')->__('Your name...') ?>';" value="<?php echo ($this->helper('contacts')->getUserName())?$this->htmlEscape($this->helper('contacts')->getUserName()):Mage::helper('contacts')->__('Your name...'); ?>" class="form-control required-entry" type="text" />
                    </div>
                    </div>
                </div></br>
                <div class="field">
                    <div class="input-box">
                    <div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i class="icon-envelope" aria-hidden="true"></i>
</span>
                        <input name="email" id="email1" title="<?php echo Mage::helper('contacts')->__('Your email') ?>" onfocus="if(this.value=='<?php echo Mage::helper('contacts')->__('Your email...') ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo Mage::helper('contacts')->__('Your email...') ?>';" value="<?php echo ($this->helper('contacts')->getUserEmail())?$this->htmlEscape($this->helper('contacts')->getUserEmail()):Mage::helper('contacts')->__('Your email...'); ?>" class="form-control required-entry validate-email" type="text" />
                    </div>
                </div>
                </div></br>
            </li>
            <li>
                <div class="input-box field">
                <div class="input-group">
            <span class="input-group-addon" id="basic-addon1"><i class="icon-pencil" aria-hidden="true"></i>
            </span>
                    <input name="subject" id="subject" title="<?php echo Mage::helper('contacts')->__('Title') ?>" onfocus="if(this.value=='<?php echo Mage::helper('contacts')->__('Subject') ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo Mage::helper('contacts')->__('Subject') ?>';" value="<?php echo ($this->helper('contacts')->getUserEmail())?$this->htmlEscape($this->helper('contacts')->getUserEmail()):Mage::helper('contacts')->__('Subject'); ?>" class="form-control" type="text" />  
                </div>
                </div></br>
            </li>
            <li class="wide">
                <div class="input-box">
                <div class="input-group">
<span class="input-group-addon" id="basic-addon1"><i class="icon-comments" aria-hidden="true"></i>
</span>
                    <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" onfocus="if(this.value=='<?php echo Mage::helper('contacts')->__('Comment...') ?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo Mage::helper('contacts')->__('Comment...') ?>';" value="<?php echo Mage::helper('contacts')->__('Comment...'); ?>" class="required-entry form-control" cols="10" rows="7"><?php echo Mage::helper('contacts')->__('Comment...') ?></textarea>
                </div>
                </div></br>
            </li>
        </ul>
    </div>
    <div class="buttons-set">
        <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
        <button type="submit" title="<?php echo Mage::helper('contacts')->__('Send Email') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Send Email') ?></span></span></button>
    </div>
</form>
<div style="clear:both; padding:15px 0px;">&nbsp;</div>

   <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('info-store')->toHtml() ?>

</div>


<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', false);
 //]]>
 </script>

This is my contact us controller kindly edit it

<?php
class Mage_Contacts_IndexController extends Mage_Core_Controller_Front_Action
{

const XML_PATH_EMAIL_RECIPIENT  = 'contacts/email/recipient_email';
const XML_PATH_EMAIL_SENDER     = 'contacts/email/sender_email_identity';
const XML_PATH_EMAIL_TEMPLATE   = 'contacts/email/email_template';
const XML_PATH_ENABLED          = 'contacts/contacts/enabled';

public function preDispatch()
{
    parent::preDispatch();

    if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
        $this->norouteAction();
    }
}

public function indexAction()
{
    $this->loadLayout();
    $this->getLayout()->getBlock('contactForm')
        ->setFormAction( Mage::getUrl('*/*/post', array('_secure' => $this->getRequest()->isSecure())) );

    $this->_initLayoutMessages('customer/session');
    $this->_initLayoutMessages('catalog/session');
    $this->renderLayout();
}

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),
                    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('*/*/');

            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('*/*/');
            return;
        }

    } else {
        $this->_redirect('*/*/');
    }
    }

}

after editing my controller is given below

class Mage_Contacts_IndexController extends Mage_Core_Controller_Front_Action
{

const XML_PATH_EMAIL_RECIPIENT  = 'contacts/email/recipient_email';
const XML_PATH_EMAIL_SENDER     = 'contacts/email/sender_email_identity';
const XML_PATH_EMAIL_TEMPLATE   = 'contacts/email/email_template';
const XML_PATH_ENABLED          = 'contacts/contacts/enabled';

public function preDispatch()
{
    parent::preDispatch();

    if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
        $this->norouteAction();
    }
}

public function indexAction()
{
    $this->loadLayout();
    $this->getLayout()->getBlock('contactForm')
        ->setFormAction( Mage::getUrl('*/*/post', array('_secure' => $this->getRequest()->isSecure())) );

    $this->_initLayoutMessages('customer/session');
    $this->_initLayoutMessages('catalog/session');
    $this->renderLayout();
    }

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),
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                    null,
                    array('data' => $postObject)
                );


$template_id = 10;

$sendername = Mage::getStoreConfig('trans_email/ident_general/name');
    $senderemail = Mage::getStoreConfig('trans_email/ident_general/email');
    $sender = Array('name' => $sendername,
    'email' => $senderemail);
$number = $name;
    $vars = Array('email' => $email,'number' => $number);
    $storeId = Mage::app()->getStore()->getId();
    $translate = Mage::getSingleton('core/translate');

       Mage::getModel('core/email_template')->sendTransactional($templateId, $sender, $emailId, $number, $vars, $storeId);

    $translate->setTranslateInline(true);



            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('*/*/');

            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('*/*/');
            return;
        }

    } else {
        $this->_redirect('*/*/');
    }
    }

    }

I have update your solution in my controller like this but bot working

<?php
class Mage_Contacts_IndexController extends Mage_Core_Controller_Front_Action
{

const XML_PATH_EMAIL_RECIPIENT  = 'contacts/email/recipient_email';
const XML_PATH_EMAIL_SENDER     = 'contacts/email/sender_email_identity';
const XML_PATH_EMAIL_TEMPLATE   = 'contacts/email/email_template';
const XML_PATH_ENABLED          = 'contacts/contacts/enabled';

public function preDispatch()
{
    parent::preDispatch();

    if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
        $this->norouteAction();
    }
}

public function indexAction()
{
    $this->loadLayout();
    $this->getLayout()->getBlock('contactForm')
        ->setFormAction( Mage::getUrl('*/*/post', array('_secure' => $this->getRequest()->isSecure())) );

    $this->_initLayoutMessages('customer/session');
    $this->_initLayoutMessages('catalog/session');
    $this->renderLayout();
}

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),
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                    null,
                    array('data' => $postObject)
                );

                //Custom email to customer starts here.
        $html="Add your email content here";
        $customemail = Mage::getModel('core/email');
        $customemail->setToEmail($post['email']);
        $customemail->setBody($html);
        $customemail->setSubject('Mail Subject');
         $customemail->setFromEmail(Mage::getStoreConfig('trans_email/ident_general/email'););
        $customemail->setFromName(Mage::getStoreConfig('trans_email/ident_general/name'););
        $customemail->setType('html');

        try {
        $mail->send();
        }
        catch (Exception $e) {
        Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
        $this->_redirect('*/*/');
                    return;
        }
        //Custom email to customer ends here



            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('*/*/');

            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('*/*/');
            return;
        }

    } else {
        $this->_redirect('*/*/');
    }
}

}
0

Magento doesn't notifies customer on contact us submit it just sends notification to admin. In case you want to achieve that you got to customize it you will need to modify the contact us controller and add the email code for customer as well also you need to create a custom email template for the customer. check below path in your magento 1 source

app/code/core/Mage/Contacts/controllers/IndexController.php

first copy your file to app/code/local/Mage/Contacts/controllers/ path in your source, if the local folder is not existing in your source then create one along with the further path till controller and place your Indexcontroller.php there and later place the below code in that local file:

//Custom email to customer starts here.
            $html="Add your email content here";
            $customemail = Mage::getModel('core/email');
            $customemail->setToEmail($post['email']);
            $customemail->setBody($html);
            $customemail->setSubject('Mail Subject');
            $customemail->setFromEmail(Mage::getStoreConfig('trans_email/ident_general/email'););
            $customemail->setFromName(Mage::getStoreConfig('trans_email/ident_general/name'););
            $customemail->setType('html');

            try {
            $mail->send();
            }
            catch (Exception $e) {
            Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
            $this->_redirect('*/*/');
                        return;
            }
            //Custom email to customer ends here
10
  • please see updated post
    – Neeya
    Dec 28 '16 at 12:34
  • kindly edit my controller
    – Neeya
    Dec 28 '16 at 12:37
  • i am new in magento please help me
    – Neeya
    Dec 29 '16 at 4:57
  • anybody knows answer please share
    – Neeya
    Dec 29 '16 at 6:38
  • check my edited answer
    – mp196
    Dec 29 '16 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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