Tuesday, August 17, 2010

Confirmation Email Facility to customer on submission of contact us form

· Open app\code\core\Mage\Contacts\etc\system.xml, and find below code,


<email_template translate="label">

<label>Email Template</label>

<frontend_type>select</frontend_type>

<source_model>adminhtml/system_config_source_email_template</source_model>

<sort_order>30</sort_order>

<show_in_default>1</show_in_default>

<show_in_website>1</show_in_website>

<show_in_store>1</show_in_store>

</email_template>

Add below code after above code in system.xml,


<confirmation_email_template translate="label">

<label>Customer Email Template</label>

<frontend_type>select</frontend_type>

<source_model>adminhtml/system_config_source_email_template</source_model>

<sort_order>30</sort_order>

<show_in_default>1</show_in_default>

<show_in_website>1</show_in_website>

<show_in_store>1</show_in_store>

</confirmation_email_template>


· Now open app\code\core\Mage\Contacts\controllers\IndexController.php & find below code,

const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template';

Add below code after above code,

const XML_PATH_CONFIRMATION_EMAIL_TEMPLATE = 'contacts/email/confirmation_email_template';

Now find below code in same file,

$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)

);

Add below code after above code,

$mailTemplate->setDesignConfig(array('area' => 'frontend'))

->setReplyTo(self::XML_PATH_EMAIL_SENDER)

->sendTransactional(

Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_EMAIL_TEMPLATE),

Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),

$post['email'],

null,

array('data' => $postObject)

);

You will need to create new email template from Admin->Configuration->Transactional Emails, & then set that new email template to Customer Email Configuration option in Email options in Contacts


Add CC to Contact Us in Magento Admin

Go to Admin Panel->System->Configuration->Contacts


Here in above screenshot you are able to see Send Email To in Email Options section.

· Now, if you want to add Send Email CC to this section, Open app\code\core\Mage\Contacts\etc\system.xml, and find below code,


<recipient_email translate="label">
<label>Send Emails To</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</recipient_email>
Add below code after above code in system.xml,


<recipient_email2 translate="label">
<label>Send Emails CC</label>
<frontend_type>text</frontend_type>
<sort_order>11</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</recipient_email2>


· Now open app\code\core\Mage\Contacts\controllers\IndexController.php & find below code,

const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email';

Add below code after above code,

const XML_PATH_EMAIL_RECIPIENT2 = 'contacts/email/recipient_email2';

Now find below code in same file IndexController.php,

$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)

);

Add below code after above code,

$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_RECIPIENT2),

null,

array('data' => $postObject)

);

Now finally you will have Send Email CC Field in Email Options, you can set different email address here & whenever user will fill contact us form in frontend Send Email CC will also receive an email for that contact inquiry.