问题
Magento
is not sending out any emails, transnational, contact form gives error
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
回答1:
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.log
found the error it was generating was:
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.php
and found the code that was throwing this error (on line 354) was:
if (!$this->isValidForSend()) {
Mage::logException(new Exception('This letter cannot be sent.')); // translation is intentionally omitted
return false;
}
So had a look at 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
:
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.log
which had:
2012-05-30T04:44:37+00:00 DEBUG (7): false;'CustomerSupport';'support@example.com';'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 Settings
and change Disable Email Communications
to No
so the emails are NOT disabled.
Now it works :)
回答2:
Any php program can do a half-decent job of sending out some email with phpmail.
Given the error message, What your Magento build is trying to do is different - use Sendmail via the Zend library.
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.
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.
Fixing your Sendmail is distro specific.
回答3:
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:
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.
Also refer to:
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
回答4:
That can be sendmail
problem, if Magento
sending emails with php
default transport.
I'm experienced with situation when sendmail deny emails for local domain, instead of relay those emails to MX servers
http://www.masterdef.net/blog/magento-unable-to-send-mail-sendmail-configuration/#more-1
I recommend check mail.log
on server, and found if there is errors like a user unknown
that mean wrong sendmail
configuration
回答5:
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.
回答6:
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 .
来源:https://stackoverflow.com/questions/9393220/magento-not-sending-out-any-mails-how-to-debug