magento 1.8.1中的联系人表单错误如何解决?
我们是新的磁电机和面临的问题,我的联系我们页面不工作时,填写表格和提交,然后将出现错误'无法提交您的请求。请稍后再试“我该怎么办?”?请帮帮我。链接magento 1.8.1中的联系人表单错误如何解决?,magento,magento-1.8,Magento,Magento 1.8,我们是新的磁电机和面临的问题,我的联系我们页面不工作时,填写表格和提交,然后将出现错误'无法提交您的请求。请稍后再试“我该怎么办?”?请帮帮我。链接 可能解决问题的第一件事是更改的以下功能 app/code/core/Mage/Core/Model/Email/Template.php copy to app/code/local/Mage/Core/Model/Email/Template.php public function setReplyTo($email) {
可能解决问题的第一件事是更改的以下功能
app/code/core/Mage/Core/Model/Email/Template.php copy to
app/code/local/Mage/Core/Model/Email/Template.php
public function setReplyTo($email)
{
$this->getMail()->addHeader('Reply-To', $email);
return $this;
}
到
app/design/frontend/YOUR_THEME/template/contacts/form.phtml
Add this after the <form> tag:
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
app/design/frontend/YOUR_THEME/template/contacts/form.phtml
在标记后添加以下内容:
联系人表单提交给该控制器
app/code/core/Mage/Contacts/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),
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;
}
在这里,您终于可以看到错误消息了。所以
去检查这个文件,这样你就能找到问题所在。此错误主要由hideit
输入字段引起。您可以在同一文件中启用此字段的验证
if (!Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}
如果你发现了这个,就把它注释掉或者用下面的替换掉
if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}
就这样。如果您有任何疑问,请在这里发表评论。亲爱的Elavarasan,我使用此代码但不工作,我认为此问题是SMTP,因为相同的代码在其他服务器上工作哦。!这可能是邮件服务器的问题。亲爱的拉维,我用了这个代码,但不工作,我想这个问题是SMTP,因为相同的代码在其他服务器上工作
if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}