$mailer->send();
I am still in setup test mode. I am trying to do end to end testing on an order using paypal with the developer feature turned on. The paypal part and actual order part is working fine. I get the order produced but I am not able to produce the order email. I can't get the Cron job to produce the email. I had two records in my cron_schedule table but they would not run. In trying to fix my issue I deleted the records. I have not been able to figure out, how do these records get loaded?
Also, I have setup my 'mail sending settings' with
host - mail.acme.com
port - 995
this is for a2 hosting. Does anyone know if this is the correct setup for that hosting service?
Also, do I need to add any userid and password to the Magento code to get the email to work for Cron? I have been able to get non order emails to send which I do not believe run on Cron.
I was able to get the Cron job to produce this in the error_log file;
PHP Notice: Undefined index: SCRIPT_NAME in /home/test/acme.com/cron.php on line 40
PHP Notice: Undefined index: SCRIPT_FILENAME in /home/test/acme.com/cron.php on line 41
My Cron job looks like this;
php -f /home/test/acme.com/cron.php | awk '{ print strftime("\%Y-\%m-\%d \%H:\%M:\%S"), $0; fflush(); }' 2>&1 >> ~/magento_cron.log
Also, I saw that potentially a cron job could be stuck on the server so I logged on using ssh and saw that there were no cron jobs out there that needed to be killed.
What do I need to do to get the cron_schedule table to load and then for the cron job to run those and send emails?
Solved! Go to Solution.
Hello @todd_a,
After changing above code, Customer will get email of order confirmation on that time otherwise it'll add in queue table then cron will send order confirmation email.
And for other email doesn't depend on cron.
--
If my answer is useful, please Accept as Solution & give Kudos
Hello @todd_a,
As mam08ixo has stated certain _SERVER properties are available on the CLI, however, due to some abnormal configuration I solved this by using php-cli:
php-cli /home/***/public_html/cron.php > /dev/null &2>1
--
If my answer is useful, please Accept as Solution & give Kudos
I made changed the cron command to
php-cli /home/***/public_html/cron.php > /dev/null &2>1
Now I do not get an error message but no order is sent. Not sure if it is working or not. I think the first thing I need to get past is loading the table cron_schedule
I think that is what drives the process. How do I get the cron_schedule table loaded and then how does that table get run through cron.
Also, I would prefer not to change the core code but I saw a possible solution by letssewilc
of
*******************************************************************************************
I have seen some people fix this type of issue by changing in the app/code/core/Mage/Sales/Model/Order.php on lines ~1356 & ~1450 from
$mailer->setQueue($emailQueue)->send();
to
$mailer->send();
Hello @todd_a,
After changing above code, Customer will get email of order confirmation on that time otherwise it'll add in queue table then cron will send order confirmation email.
And for other email doesn't depend on cron.
--
If my answer is useful, please Accept as Solution & give Kudos
The solution for me was to change the two lines of code in app/code/core/Mage/Sales/Model/Order.php I spent a lot of time trying to make Cron work and in retrospect this was very easy solution and it's only two lines of code. Anyone can make this change without wrecking their setup. Just back up the original file make the change and see if it fixes the problem.
This is such an easy solution and for me it makes a lot more sense to immediately send the order email rather than to wait for a Cron job to send.
One other issue trying to fix the Order email/Cron problem I ran into... I spent a lot of time and tried a lot of tactics to try to make Cron work. One of the things I did was turn the debugger on. Once I found my solution, I forgot that I had turned debugger on because I had tried so many different things. So after issue was fixed, I went back to work on my website. However, my back and and front end speed went to a crawl after a few clicks and I could not do anything. I attributed the slowness to my host provider and wasted a weekend thinking they would fix it. I finally realized it was because I had my debugger turned on in magento. So for other new magento folks, turn off the debugger whenever possible. It wrecks the website for any other use.
One more thing to add on changing the two lines of core code. Once you make the change you need to compile for it to take affect. Otherwise the order will continue to go to the core_email_queu table.
system -> Tools -> Compilation then click the run compilation