4

I'm new to Magento. I've upgraded recently magento to 1.9.2 and it's not sending new order confirmation emails.

I checked email templates and they're in place (I use default magento templates from locale folder).

Exception log shows these errors:

2015-08-12T12:00:04+00:00 ERR (3): 
exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. ' in /home/user/webapps/app_name/lib/Zend/Mail/Transport/Sendmail.php:137
Stack trace:
#0 /home/user/webapps/app_name/lib/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Sendmail->_sendMail()
#1 /home/user/webapps/app_name/lib/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#2 /home/user/webapps/app_name/app/code/core/Mage/Core/Model/Email/Queue.php(239): Zend_Mail->send()
#3 [internal function]: Mage_Core_Model_Email_Queue->send(Object(Aoe_Scheduler_Model_Schedule))
#4 /home/user/webapps/app_name/app/code/community/Aoe/Scheduler/Model/Observer.php(79): call_user_func_array(Array, Array)
#5 /home/user/webapps/app_name/app/code/core/Mage/Core/Model/App.php(1357): Aoe_Scheduler_Model_Observer->dispatch(Object(Varien_Event_Observer))
#6 /home/user/webapps/app_name/app/code/core/Mage/Core/Model/App.php(1336): Mage_Core_Model_App->_callObserverMethod(Object(Aoe_Scheduler_Model_Observer), 'dispatch', Object(Varien_Event_Observer))
#7 /home/user/webapps/app_name/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
#8 /home/user/webapps/app_name/cron.php(76): Mage::dispatchEvent('default')
#9 {main}

My cron settings:

cron settings

Aoe scheduler shows that heartbeat is older than x minutes:

aoe scheduler timeline

I'm on shared server and I don't have access to mail logs, but my host provider checked it for me and they said there was no emails that match up time wise for orders that were placed. They also checked if cron.sh and cron.php run properly.

7

The cronjob is working (otherwise you would not get this exception) and if your hoster said, that Magento did not try to send any emails, the exception has another reason.

Unfortunately the message is not very precise, but you do get it when the email has no subject or no recipient, so you should double check your email templates and your sales email configuration.

To debug, I suggest to inspect the parameters for mail(): Edit lib/Zend/Mail/Transport/Sendmail.php around line 100 and replace:

set_error_handler(array($this, '_handleMailErrors'));
$result = mail(
    $this->recipients,
    $this->_mail->getSubject(),
    $this->body,
    $this->header);
restore_error_handler();

with

set_error_handler(array($this, '_handleMailErrors'));

Mage::log("MAIL RECIPIENTS: " . $this->recipients, null, 'mail.log', true);
Mage::log("MAIL SUBJECT: " . $this->_mail->getSubject(), null, 'mail.log', true);

$result = mail(
    $this->recipients,
    $this->_mail->getSubject(),
    $this->body,
    $this->header);
restore_error_handler();

Then check var/log/mail.log after a failed email to see if recipients or subject are missing.

  • Tried to change your error with the :... Needed to edit at least 6 characters... – Max Nov 9 '16 at 16:29
  • You're welcome, @fschmengler. :) – Max Nov 10 '16 at 13:23
6

If you are seeing exceptions from Zend_Mail then I would say your mail setup on your server is not working. Do you have command line access to the server? You can test mail simply with the command

echo "This is a test." | mail -s Testing your@email.address

Once command line mail is working you can troubleshoot mail further, perhaps there is a permissions problem, or php problem. Create the following test-email.php file in your Magento installation folder:

<?php 
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "emailtest@YOURDOMAIN";
$to = "YOUREMAILADDRESS";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
?>

Add your address info and execute the file from both the command line

php test-email.php

and the web browser

http://www.yourshop.domain/test-email.php

I expect this to fail, take a note of the error message that you see.

  • Yes, I have access to command line. I tested it and it's working. – webhappy Aug 18 '15 at 8:33
  • Ok, I expect this is a permissions or php problem, I have updated my answer please test email with php from the command line and browser. – paj Aug 18 '15 at 9:16
  • Thank you very much for your help. So I created that file and when I executed from web browser Test email was sent and delivered to my email address. But when I executed from command line I got this error: Could not open input file: test-email.php – webhappy Aug 18 '15 at 10:27
  • did you run php test-email-php from your Magento installation folder? – paj Aug 18 '15 at 10:30
  • I added test-email.php file into Magento root directory – webhappy Aug 18 '15 at 10:52
4

Three days were spent investigating and addressing those hiccups, and I can now share my newly found knowledge of the possible problems arising from updating Magento to 1.9.

First of all, Magento 1.9+ relies completely on cron jobs to send transactional emails. If you didn’t have cron jobs set up properly before, you are going to have to do it now.

First of all make sure you have set up cron tasks in the Magento admin under System > Configuration > Advanced > System > Cron. The default settings are:

Generate Schedules Every 15 Schedule Ahead for 20 Missed if Not Run Within 15 History Cleanup Every 10 Success History Lifetime 60 Failure History Lifetime 600

There are people suggesting these settings should be changed, but since they can’t seem to agree on the best combination, I’d rather leave it as it is.

You then need to go into your hosting control panel and set up cron jobs. In cPanel it’s under Advanced > Cron Jobs. Set them up to run every five minutes and use this command:

php -f /home/username/public_html/cron.php

Check that the above path is correct and that the file cron.php is actually there in the root of your Magento installation (if you’ve just upgraded, it should be). Change username to the correct account.

Now, I initially made the mistake of following the advice of the developers at xtento.com who say to use a wget command string: wget -O /dev/null -q http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php.

This did not work for me at all, whereas the php command did, so my advice is: stick with that.

1

If heartbeat is older than 5 minutes, and you have the heartbeat task set to run every 5 minutes, then your issue is cron. Check cron tab settings on server?

1

I used this cron job command in C-Panel-> Cron Jobs and I received the order confirmation emails. Please place your username with your hosting account and subdomain if necessary

php -f /home/YOUR-USERNAME/public_html/IF-SUBDOMAIN-HERE/cron.php
-1

Hey man i just had resolved this issue 5 minutes ago. all i did was unzip the gmailsmtp file where you will find inside app , then rename the file module.xml to modules.xml.. Thats how it worked for me. hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.