php magento 不发送任何邮件,如何调试?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9393220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:42:53  来源:igfitidea点击:

magento not sending out any mails, how to debug?

phpdebuggingmagentozend-frameworkzend-mail

提问by Ilse

Magentois not sending out any emails, transnational, contact form gives error

Magento不发送任何电子邮件,跨国,联系表出错

 cannot send your mail at this moment

I checked

我检查了

  • Mail setup in magento, all email accounts are set in settings
  • php mail works fine a test.php with php mail sends out a message
  • checked my mailserver logs but see nothing there no errors
  • /var/log/system.log and exception.log shows only an error not the cause of the error

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

  • 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

回答by Kus

I ran into this problem when Magento was not sending out forgot password emails (yet reporting it did to the user) then after looking in /var/log/exception.logfound the error it was generating was:

当 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}

So opened up /app/code/core/Mage/Core/Model/Email/Template.phpand found the code that was throwing this error (on line 354) was:

所以打开/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;
}

So had a look at isValidForSend():

所以看看isValidForSend()

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

Added some logging of the variables at the start of the function as one of these must be returning false:

在函数开始时添加了一些变量日志记录,因为其中之一必须返回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');

Which creates the log file /var/log/email.logwhich had:

它创建的日志文件/var/log/email.log具有:

2012-05-30T04:44:37+00:00 DEBUG (7): false;'CustomerSupport';'[email protected]';'Password Reset Confirmation for {{var customer.name}}'

So the problem was: !Mage::getStoreConfigFlag('system/smtp/disable')which you can fix up in Admin > System > Configuration > Advanced > System > Mail Sending Settingsand change Disable Email Communicationsto Noso the emails are NOTdisabled.

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

Now it works :)

现在它起作用了:)

回答by ??????

Any php program can do a half-decent job of sending out some email with phpmail.

任何 php 程序都可以完成使用 phpmail 发送一些电子邮件的半体面工作。

Given the error message, What your Magento build is trying to do is different - use Sendmail via the Zend library.

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

You will need to build and test your sendmail installation. Or use some other mail service such as gmail and get Magento to use that.

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

To test whether it is you, your computer or Magento, put some other program such as Roundcube Mail on there. If Roundcube Mail can send mail then you will know Sendmail is working, if not then you will know the problem is in Sendmail.

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

Fixing your Sendmail is distro specific.

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

回答by Gerard de Visser

I also struggled with the problem of order e-mails not being sent in CE 1.9.1 but found the problem after a while:

我也在 CE 1.9.1 中无法发送订单电子邮件的问题上苦苦挣扎,但过了一会儿发现了问题:

As of Magento CE 1.9.1 Magento doesn't send order emails directly during the order process. Instead the mails are queued and are sent by the cron. So make sure to configure the Magento cronjob properly.

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

Also refer to:

另请参考:

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

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

回答by Harry Thakkar

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

also, in my case error log took me to this function. Configuration in admin was fine. But $this->getTemplateSubject() was sending false value as template was missing under /app/locale/ folder. So added template that was missing. After that it worked for me.

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

回答by XPS

That can be sendmailproblem, if Magentosending emails with phpdefault transport.

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

I'm experienced with situation when sendmail deny emails for local domain, instead of relay those emails to MX servers

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

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

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

I recommend check mail.logon server, and found if there is errors like a user unknownthat mean wrong sendmailconfiguration

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

回答by Saleh Galiwala

If there is a problem with the email template .You get this error.So before checking the email logs check your email template , moreover when its a custom email template , the code is not broken .

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