Magento only sends order confirmation emails when manually prompted to

3.2k views Asked by At

A Magento website I'm maintaining stopped sending order confirmations and/or invoices all of a sudden.

Nothing has been changed in the email settings and they're all complying with common Magento guidelines. I've tried sending a test email through the following php script to make sure it's not caused by any server settings:

    <?php
$to = "[email protected]";
$subject = "Test email";
$message = "This is a test email.";
$from = "[email protected]";
$headers = "From:" . $from;
if (mail($to, $subject, $message, $headers)) {
    echo("Your message has been sent successfully");
    } else {
    echo("Sorry, your message could not be sent");
}
?>

The test message got delivered flawlessly.

I installed the SMTP Pro Email plugin to see if changing settings there would manage a result; nothing. The plugin offers the ability to send a test email, which again gets delivered without flaw.

Even stranger, clicking the 'Send Email' button in the Magento backend for an order does deliver the email. Signing up for a newsletter does result in a subscription confirmation request email. Clearly, the website can send mails, it just somehow doesn't get triggered to do so for order order confirmations and invoices.

And yes, both

System > Configuration > Sales > Sales Emails > Order > Enabled

and

System > Configuration > Sales > Sales Emails > Invoice > Enabled

are set to Yes and include a BCC address.

Similarly,

System > Configuration > Advanced > System > Mail Sending Settings > Disable Email Communications

is set to No.

I'm running Magento CE 1.6.2 on this site, so it's not the common cron job problem version 1.9 seems to cause for a lot of folk.

I'm racking my brain here, does anybody have a clue?

2

There are 2 answers

0
Adje On

Still haven't found what causes the problem, but added some code to succes.phtml to force the mail to be sent upon loading that page:

<?php
$order = new Mage_Sales_Model_Order();
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();

$order->loadByIncrementId($incrementId);

try
{
$order->sendNewOrderEmail();
} catch (Exception $ex) {  }
?>

It's not the most elegant solution, but at least the customers get their order confirmation through this workaround.

0
Lambert Matias On

I am using version 1.8.1. I have been fighting with this same problem for 2 weeks now. The simple solution came by me "enabling" every option in System > Configuration > Advanced. All the new order confirmations get sent out immediately now to the person placing the order.

Background: After installing and configuring the new Magento Cart, I noticed that emails were only going through if I manually sent them through the admin screens. This told me that the server SMTP settings were correct, but I was wondering why a person placing an order would not receive the confirmation email...ever. After much searching and reading I thought that it had to do with one of the other functions of the Magento cart. So I went into the system confuration under the advanced tab (System > Configuration > Advanced) and found that I had disabled certain things like Sendtofrined, Newsletter, etc. Not wanting to waste time at the moment, I simply went through the entire list and enabled everything. Now I have the coupon function, add to wish list function and newsletter stuff that I do not want to see in the cart, but the emails are going through immediately and reliably. I will now attempt to find which function is related to the order confirmation email by process of elimination. But this did the trick for me and I hope it helps someone else out there, without having to add code to the php files.