12

Magento没有发送任何电子邮件,跨国,联系表格给出错误

 cannot send your mail at this moment

我检查了

  • Magento中的邮件设置,所有电子邮件帐户都在设置中设置
  • php邮件工作正常一个带有php邮件的test.php发出一条消息
  • 检查了我的邮件服务器日志,但什么也没看到,没有错误
  • /var/log/system.log 和 exception.log 仅显示错误而不是错误原因

    exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. ' in /var/webshop/httpdocs/lib/Zend/Mail/Transport/Sendmail.php:137

4

6 回答 6

26

当 Magento 没有发送忘记密码的电子邮件(但向用户报告它)时,我遇到了这个问题,然后在查看后/var/log/exception.log发现它生成的错误是:

2012-05-30T04:27:54+00:00 ERR (3): 
exception 'Exception' with message 'This letter cannot be sent.' in /home/magento/www/app/code/core/Mage/Core/Model/Email/Template.php:354
Stack trace:
#0 /home/magento/www/app/code/core/Mage/Core/Model/Email/Template.php(463): Mage_Core_Model_Email_Template->send(Array, Array, Array)
#1 /home/magento/www/app/code/core/Mage/Core/Model/Email/Template/Mailer.php(79): Mage_Core_Model_Email_Template->sendTransactional('customer_passwo...', 'support', Array, Array, Array, '1')
#2 /home/magento/www/app/code/core/Mage/Customer/Model/Customer.php(646): Mage_Core_Model_Email_Template_Mailer->send()
#3 /home/magento/www/app/code/core/Mage/Customer/Model/Customer.php(663): Mage_Customer_Model_Customer->_sendEmailTemplate('customer/passwo...', 'customer/passwo...', Array, '1')
#4 /home/magento/www/app/code/core/Mage/Customer/controllers/AccountController.php(554): Mage_Customer_Model_Customer->sendPasswordResetConfirmationEmail()
#5 /home/magento/www/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Customer_AccountController->forgotPasswordPostAction()
#6 /home/magento/www/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('forgotpasswordp...')
#7 /home/magento/www/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#8 /home/magento/www/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
#9 /home/magento/www/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#10 /home/magento/www/index.php(84): Mage::run('default', 'store')
#11 {main}

因此打开/app/code/core/Mage/Core/Model/Email/Template.php并发现引发此错误的代码(在第 354 行)是:

if (!$this->isValidForSend()) {
    Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
    return false;
}

所以看看isValidForSend()

public function isValidForSend()
{
    return !Mage::getStoreConfigFlag('system/smtp/disable')
        && $this->getSenderName()
        && $this->getSenderEmail()
        && $this->getTemplateSubject();
}

在函数开头添加了一些变量日志记录,因为其中之一必须返回false

Mage::Log(var_export(!Mage::getStoreConfigFlag('system/smtp/disable'),true).';'.var_export($this->getSenderName(),true).';'.var_export($this->getSenderEmail(),true).';'.var_export($this->getTemplateSubject(),true),null,'email.log');

这会创建具有以下内容的日志文件/var/log/email.log

2012-05-30T04:44:37+00:00 DEBUG (7): false;'CustomerSupport';'support@example.com';'Password Reset Confirmation for {{var customer.name}}'

所以问题是:!Mage::getStoreConfigFlag('system/smtp/disable')您可以修复Admin > System > Configuration > Advanced > System > Mail Sending Settings并更改Disable Email Communications为,No这样电子邮件就不会被禁用。

现在它可以工作了:)

于 2012-05-30T04:55:51.170 回答
2

任何 php 程序都可以用 phpmail 发送一些电子邮件。

鉴于错误消息,您的 Magento 构建尝试做的是不同的 - 通过 Zend 库使用 Sendmail。

您将需要构建和测试您的 sendmail 安装。或者使用其他一些邮件服务,例如 gmail 并让 Magento 使用它。

要测试是您、您的计算机还是 Magento,请在其中放置一些其他程序,例如 Roundcube Mail。如果 Roundcube Mail 可以发送邮件,那么您将知道 Sendmail 正在工作,否则您将知道问题出在 Sendmail 中。

修复您的 Sendmail 是特定于发行版的。

于 2012-02-22T16:55:47.737 回答
2

我也为在 CE 1.9.1 中无法发送订单电子邮件的问题而苦苦挣扎,但一段时间后发现了问题:

从 Magento CE 1.9.1 开始,Magento 不会在订购过程中直接发送订购电子邮件。相反,邮件排队并由 cron 发送。因此,请确保正确配置 Magento cronjob。

另请参阅:

http://www.magentocommerce.com/knowledge-base/entry/ee1141-ce191-responsive-email#cron http://www.magentocommerce.com/knowledge-base/entry/ce18-and-ee113-installing#install -cron

于 2015-01-27T10:33:37.580 回答
1

如果使用默认传输方式发送电子邮件,这可能是sendmail个问题。Magentophp

我遇到过 sendmail 拒绝本地域的电子邮件,而不是将这些电子邮件中继到 MX 服务器的情况

http://www.masterdef.net/blog/magento-unable-to-send-mail-sendmail-configuration/#more-1

我建议检查mail.log服务器,并发现是否有错误user unknown 意味着错误的sendmail配置

于 2013-07-11T17:39:16.230 回答
1
public function isValidForSend()
{
    return !Mage::getStoreConfigFlag('system/smtp/disable')
        && $this->getSenderName()
        && $this->getSenderEmail()
        && $this->getTemplateSubject();
}

另外,在我的情况下,错误日志将我带到了这个功能。管理员中的配置很好。但是 $this->getTemplateSubject() 正在发送错误值,因为 /app/locale/ 文件夹下缺少模板。所以添加了丢失的模板。之后它对我有用。

于 2016-08-02T06:41:48.100 回答
0

如果电子邮件模板有问题。您会收到此错误。因此,在检查电子邮件日志之前,请检查您的电子邮件模板,此外,当它是自定义电子邮件模板时,代码不会损坏。

于 2014-03-19T17:49:27.577 回答