diff --git a/app/code/core/Mage/Contacts/controllers/IndexController.php b/app/code/core/Mage/Contacts/controllers/IndexController.php
index 12f9ba6739a..42cf817ed77 100644
--- a/app/code/core/Mage/Contacts/controllers/IndexController.php
+++ b/app/code/core/Mage/Contacts/controllers/IndexController.php
@@ -21,10 +21,12 @@
*/
class Mage_Contacts_IndexController extends Mage_Core_Controller_Front_Action
{
- public const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email';
- public const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity';
- public const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template';
- public const XML_PATH_ENABLED = 'contacts/contacts/enabled';
+ public const XML_PATH_ENABLED = 'contacts/contacts/enabled';
+ public const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity';
+ public const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email';
+ public const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template';
+ public const XML_PATH_AUTO_REPLY_ENABLED = 'contacts/auto_reply/enabled';
+ public const XML_PATH_AUTO_REPLY_EMAIL_TEMPLATE = 'contacts/auto_reply/email_template';
/**
* @return $this
@@ -61,23 +63,21 @@ public function postAction()
$postObject = new Varien_Object();
$postObject->setData($post);
+ // check data
$error = false;
-
if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
$error = true;
- }
-
- if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
+ } elseif (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
$error = true;
- }
-
- if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
+ } elseif (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
$error = true;
}
if ($error) {
- throw new Exception();
+ Mage::throwException($this->__('Unable to submit your request. Please, try again later'));
}
+
+ // send email
$mailTemplate = Mage::getModel('core/email_template');
/** @var Mage_Core_Model_Email_Template $mailTemplate */
$mailTemplate->setDesignConfig(['area' => 'frontend'])
@@ -91,24 +91,36 @@ public function postAction()
);
if (!$mailTemplate->getSentSuccess()) {
- throw new Exception();
+ Mage::throwException($this->__('Unable to submit your request. Please, try again later'));
}
- $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('*/*/');
+ // send auto reply email to customer
+ if (Mage::getStoreConfigFlag(self::XML_PATH_AUTO_REPLY_ENABLED)) {
+ $mailTemplate = Mage::getModel('core/email_template');
+ /** @var Mage_Core_Model_Email_Template $mailTemplate */
+ $mailTemplate->setDesignConfig(['area' => 'frontend'])
+ ->setReplyTo(Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT))
+ ->sendTransactional(
+ Mage::getStoreConfig(self::XML_PATH_AUTO_REPLY_EMAIL_TEMPLATE),
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
+ $post['email'],
+ null,
+ ['data' => $postObject]
+ );
+ }
- 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;
+ Mage::getSingleton('customer/session')->addSuccess($this->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
+ } catch (Mage_Core_Exception $e) {
+ $translate->setTranslateInline(true);
+ Mage::logException($e);
+ Mage::getSingleton('customer/session')->addError($e->getMessage());
+ } catch (Exception $e) {
+ Mage::logException($e);
+ Mage::getSingleton('customer/session')->addError($this->__('Unable to submit your request. Please, try again later'));
}
- } else {
- $this->_redirect('*/*/');
}
+
+ $this->_redirect('*/*/');
}
}
diff --git a/app/code/core/Mage/Contacts/etc/config.xml b/app/code/core/Mage/Contacts/etc/config.xml
index 951dbaa6d24..0234162fc4e 100644
--- a/app/code/core/Mage/Contacts/etc/config.xml
+++ b/app/code/core/Mage/Contacts/etc/config.xml
@@ -62,10 +62,14 @@
contact_form.htmltext
+
+
+ contact_form_auto_reply.html
+ html
+
-
@@ -77,7 +81,6 @@
-
diff --git a/app/code/core/Mage/Contacts/etc/system.xml b/app/code/core/Mage/Contacts/etc/system.xml
index 9b0c674f17b..dfdcaffcb49 100644
--- a/app/code/core/Mage/Contacts/etc/system.xml
+++ b/app/code/core/Mage/Contacts/etc/system.xml
@@ -50,34 +50,62 @@
11
+
+
+ select
+ adminhtml/system_config_source_email_identity
+ 10
+ 1
+ 1
+ 1
+ validate-email required-entry
- 10
+ 20111
-
-
+
+
select
- adminhtml/system_config_source_email_identity
- 20
+ adminhtml/system_config_source_email_template
+ 30111
-
+
+
+
+
+
+ 50
+ 1
+ 1
+ 1
+
+
+
+ Warning! Enabling this feature may cause unwanted messages to be sent to people whose email addresses are being used abusively. Please make sure that you have implemented security measures before enabling (e.g. CAPTCHA, HoneySpam).]]>
+ select
+ adminhtml/system_config_source_yesno
+ 91
+ 1
+ 1
+ 1
+ selectadminhtml/system_config_source_email_template
- 30
+ 92111
-
+
diff --git a/app/locale/en_US/Mage_Contacts.csv b/app/locale/en_US/Mage_Contacts.csv
index 277333d7e51..8daacc3586f 100644
--- a/app/locale/en_US/Mage_Contacts.csv
+++ b/app/locale/en_US/Mage_Contacts.csv
@@ -1,6 +1,9 @@
"* Required Fields","* Required Fields"
+"Auto Reply","Auto Reply"
+"Warning! Enabling this feature may cause unwanted messages to be sent to people whose email addresses are being used abusively. Please make sure that you have implemented security measures before enabling (e.g. CAPTCHA, HoneySpam).","Warning! Enabling this feature may cause unwanted messages to be sent to people whose email addresses are being used abusively. Please make sure that you have implemented security measures before enabling (e.g. CAPTCHA, HoneySpam)."
"Comment","Comment"
"Contact Form","Contact Form"
+"Contact Form Auto Reply","Contact Form Auto Reply"
"Contact Information","Contact Information"
"Contact Us","Contact Us"
"Contact Us Form","Contact Us Form"
@@ -10,9 +13,10 @@
"Email Sender","Email Sender"
"Email Template","Email Template"
"Enable Contact Us","Enable Contact Us"
+"Enable Auto Reply","Enable Auto Reply"
+"Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.","Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us."
"Name","Name"
"Send Emails To","Send Emails To"
"Submit","Submit"
"Telephone","Telephone"
"Unable to submit your request. Please, try again later","Unable to submit your request. Please, try again later"
-"Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.","Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us."
diff --git a/app/locale/en_US/template/email/contact_form_auto_reply.html b/app/locale/en_US/template/email/contact_form_auto_reply.html
new file mode 100644
index 00000000000..39f0da615ad
--- /dev/null
+++ b/app/locale/en_US/template/email/contact_form_auto_reply.html
@@ -0,0 +1,11 @@
+
+
+
+Thank you for contacting us. We will reply you shortly.
+
+If you received this message without using the contact form on our website, please ignore it.