Contact Form Error Even Though Email is Sent

emailerrorforms

we moved our magento shop to another hosting and now visitors, who use the contact form, get an error message, even though the e-mail is sent successfully.

We didn't change anything in the core files or the template files of the contact form.

The hosting provider told us, that is has to be an error or bug in magento.

I thought about editing the core files, which produce that error, but that would not be a good idea in my opinion, because there is obviously something going wrong.

Did anyone of you run into a similar problem?

Thank you!

Error Message (English):

Unable to submit your request. Please try again later.

Solution:

Thanks to the hint from Fabian Blechschmidt, I found the exact exception:

Unable to send mail. mail(/var/log/mail.php.log): failed to open stream: Permission denied

Even though chmod 777 was set for the log-folder, magento can't create the "mail.php.log"-file on the server. But why?

It turned out that the path "/var/log/" does not mean the path from the magento root, but from the apache root. Therefore, the folder "/var/log" does not exist and can not be created by PHP.

This path is defined by the "mail.log" value in the php.ini. Because I don't need any tracking of mails sent by the server, I just removed this value and everything is working as expected now!

It was no magento-problem, but a wrong server configuration.

Once again, thanks everyone!

Best Answer

Just dig.

Your Exception is thrown here: app/code/core/Mage/Contacts/controllers/IndexController.php:107

therefore $mailTemplate->getSentSuccess() must be false

It is set false here: app/code/core/Mage/Core/Model/Email/Template.php:479

but the mail is going out, so this code is executed and send() returns false:

app/code/core/Mage/Core/Model/Email/Template.php:506
$this->setSentSuccess($this->send($email, $name, $vars));

this means, this code is executed:

app/code/core/Mage/Core/Model/Email/Template.php:453
    try {
        $mail->send();
        $this->_mail = null;
    }
    catch (Exception $e) {
        $this->_mail = null;
        Mage::logException($e);
        return false;
    }

Most likely Zend_Mail_Transport_Sendmail is used, so it continues here:

\Zend_Mail_Transport_Sendmail::_sendMail

What ever happens there, I would think throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr); is thrown.

This means for me, you should add some logging here \Zend_Mail_Transport_Sendmail::_handleMailErrors ,because of the catched and newly thrown Exception (app/code/core/Mage/Core/Model/Email/Template.php:453) all the errors descriptions are gone.

But the error should be logged in exception.log. Did you check it? If not, read this: Fundamentals of debugging Magento