Why is Magento not sending emails?
You might come across this error several times, but you do not know how to get rid of it.
Fortunately, we provide a complete tutorial here so that you will not have to search why is Magento not sending emails any longer.
I. Methods of Sending Emails in Magento
Basically, there are two methods:
– Sending emails by queue: All the data of emails that haven’t been sent will be saved into the database (table core_email_queue and core_email_queue_recipients). When the queue gets its turn, those data will be matched and sent. According to the Release note, from Magento 1.9.1, all of the emails, including confirmation email and transaction emails, are set to queue and sent based on cronjob configuration. Therefore, you need to set up a cron in order that your online shop can send emails in a smooth way.
– Sending emails directly: Usually, sending these emails is activated in event observers or controllers of the added modules via default email send function of PHP or Zend_mail. Because emails are not sent by queue, we can debug code more easily and conveniently when errors are reported.
II. When Is Magento Not Sending Emails?
You might also handle THIS ERROR Fail to Upload Magento 2 Email Logo.
1. Check configuration in admin page
To do that, you can follow this sequence: System –> Configuration –> Advanced –> System –> Mail Sending option. At “Disable Email Communications” options, lets choose “No”.
2. As for emails not being sent by queue
2.1. Check server configuration
Try running this:
<?php
mail ('you@example.com', "Test Postfix", "Test mail from postfix");
?>
in which: you@example.com is your email address. If you don’t receive any email, that means you need to check server settings
2.2. Find errors in email sending process
During doing debug, we should place the code for sending emails in try{….} catch….. and print out exception message to know causes of the error. Previously, you can also check system.log and excepton.log files (Remember to go to System/Configuration/Developer to enable log function)
Some modules also have their own log enabling function (and write into a seperate file). Aschroder’s SMTP Pro, for example.
3. As for emails using queue
In order to run cyclical sending, emails using queue need to wait until cronjob is set up. Belows are the ways how we can check it
3.1. Check and Setup by SSH
Log in SSH cient and type crontab -l. If there is cronjob leading to cron.php file or cron.sh then the result will show up:
If cronjob needs to be re-setup, we type crontab -e. Now, edit cronjob window appears. When fixing content is done, press Ctrl+O to save, then Ctrl+X to exit
3.2. Check and setup by cpanel
Log in cpanel and click at the icon of Cron jobs
– If there is cronjobs already:
– If new cronjob needs to be set up:
3.3. Check by waitng cron to be executed
Open cron.php file and add these lines into dispatchEvent part
Mage::dispatchEvent('default'); $log = fopen(__FILE__.'.log', 'a'); fwrite($log, date("Y-m-d H:i:s").PHP_EOL); fclose($log);
So, each time cron file is run will make log cron.php.log in var/log and by checking that point of time we can come to the conclusion.
3.4. Check conflicts among modules
When Magento is installed different modules at the same time to support sending emails, they may conflict and cause errors. For instance: Using SMTP Pro (old version) and Mailchimp together will make sending emails impossible because they both overwrite and extend function in Mage_Core_Model_Email_Template. In that case, we must fix the code to eliminate conflicts or disable a module.
Please vote or share if you find this one useful. Or let us know what you think about it in the comment below.
As many people also search for Magento 2 not sending emails, we will update you with the tutorial to fix “Why is Magento 2 not sending email?” later on.
CONTACT BSS Commerce if you have any other questions.
We are one of the leading Magento extension providers and web development services in the world. With experienced and certified Magento developers, we commit to bring high-quality products and services to optimize our business effectively. Let us know about your problems. We are willing to support you every time.