Magento email notifications stopped sending?

During a Magento migration some issues can arise, one of them being notification emails to both admin and users stop being sent. Apparently this is a tricky one for alot of people to find a solution for.  Here is my fix, hopefully it prevents someone from repeatedly smashing their face against a wall =)

By default Magento has a decent set of default functionality for cron jobs setup.  One thing than can happen during an upgrade is the magento mail que will stop communicating with server.

NOTE:  Older versions of Magento send notification emails instantly, Magento 1.9.x stores the email notifications in the database table “core_email_queue” so check here if you want to see if the table is full, if it is you may have a cron issue.

OPTION 1

1. The first thing to check is your CPANEL -> CRON JOBS section see if there is anything already setup.

2. Check Magento cron file is typically in the Magento Root

‘http://www.mywebsite.com/path/to/magento/cron.php’

3. In the CPANEL -> CRON JOBS section add in
Here is the full code sample:
*/15 * * * * curl -s -o /dev/null http://www.mywebsite.com/path/to/magento/cron.php

IN CPANEL CRON TAB THE ABOVE CODE IS BROKEN DOWN INTO INPUT FORM DATA
*/15 in the ‘minute’ field
* is the ‘hour’ field
* is the ‘day’ field
* is the ‘month’ field
* is the ‘weekday’ field
curl -s -o /dev/null http://www.mywebsite.com/path/to/magento/cron.php in the command field.

This should enable Magento the ability to send out the mail that is stored in the que.

Remember if you want to test the cron job you can enter in an email address in cpanel after testing to stop cron email spam.

 

OPTION 2

Use a special cron management Magento  extension AOE SCHEDULER – This plugin should be included in the Magento Core by default, that is how awesome this extention is!

 

This will show all cron tabs in Magento and allow you to see what is being processed and what’s not.

If there is a problem with the heartbeat cron job then you are on the right track…it is a cron issue not setup properly.

 

NOTE: for some configurations adding 1 piece of code to magento cron.php

<code> $isShellDisabled = (stripos(PHP_OS, ‘win’) === false) ? $isShellDisabled : true; </code>
ADD AFTER

<code> $isShellDisabled = true; </code>

 

Go back through CLI or CPANEL CRON TAB and make sure you are running “*/5 * * * * php -q path/to/magento/cron.php”

 

GO BACK TO AOE SCHEDULER IN MAGENTO – 

select the core_email_queue_send_all cron task and select RUN from the drop and then submit

Go back to phpmyadmin or sqli and look up your `core_email_queue` database table, which should be empty meaning the email sent.

Go back to AOE Scheduler and look at the visual timeline to see if all the cron jobs are processing correctly.

STILL GETTING ERRORS: If you see errors about cron jobs timing out in AOE Scheduler like the sample error below, adjust your cron settings in magento

SAMPLE ERROR:
Message: exception ‘Mage_Core_Exception’ with message ‘Too late for the schedule.’ in /home/path/to/shop/app/Mage.php:595

RE-ADJUST MAGENTO CRON SETTINGS:

If the cronjob runs every 5 minutes, try this configuration:

Generate Schedules Every  5
(enter here the cronjob execution time, in this case 5 minutes)

Schedule Ahead for  125
(based on cronjob execution time plus the maximum time one job needs. For example: sitemap xml takes 120 minutes, then enter 120 minutes + 5 = 125 minutes)

Missed if Not Run Within  180
(rumtime of the longest process, for example: an import takes 120 minutes, then enter 120 minutes + 60 minutes – because sometimes there is a difference between mysql and server time)

History Cleanup Every  10
(minimum cronjob execution time = 5 * 2 = 10 minutes in this case)

Success History Lifetime  1440
(duration of cronjob storage, to prove if everything works fine. 1440 = 24 hours)

Failure History Lifetime  1440
(duration of cronjob storage, to prove if there are any errors. 1440 = 24 hours)

 

Magento Error 503: Service Temporarily Unavailable

Just install a plugin or use magento connect with cache management enabled?  You will probably see this error.

Error 503: Service Temporarily Unavailable

The quick resolution is to ftp to the root of the magento install directory and find maintenance.flag.

Delete this flag and refresh your page and you should have access to your shopping cart again!

Magento Migration

OLD ADMIN

1 – clear cache and index management (also manually the var/cache/folders)

2- backup and export database through phpmyadmin (magento backup has issues) utf8/primary key

3- backup file/folder structure

 

NEW INSTALL

1 – install blank database

2- upload file/folder structure (you may need to CHMOD new directories to their appropriate permissions on some installs)

3-  import magento backup db (NOTE: when importing through phpmyadmin make sure to UNCHECK THE PHP TIMEOUT, this will sometimes causes primary keys/indexes to break or get left out, due to sql formatting.

 

IF YOU NEED TO REINSTALL – Sometimes if you are installing an existing db you will receive “magento already installed” error…to correct, open the magento root on your server and go to app/etc folder and delete the local.xml file, it will then display the install screen.

 

WHEN MIGRATING FROM OTHER SERVER – you may have to change path url temporarily or for a new domain

UPDATE core_config_data SET value="http://whatever.com/" WHERE path="web/unsecure/base_url";
UPDATE core_config_data SET value="https://whatever.com/" WHERE path="web/secure/base_url"

URL REWRITE ISSUES - IF SET TO 1 CHANGE TO 0 TO DISABLE - RE-ENABLE AFTER INDEX/CACHE MANAGEMENT ENABLED.

4. login to magento admin and re-assign index and cache management

 

NOTES AND ERRORS: You may receive a few issues with duplicate records, primary key disappearing, template not displaying and urls not relinking properly.