Magento email problem solving tips
Magento email problem debugging can be very embarrassing. If you ever did a research why emails are not sent or not transmitted to customer inbox, you may know how difficult it is to find the solution. In this post, I give you some hints on how to find errors, where to debug and everything you need to know.
Magento email problem
Emails are special. Email sending works fine for your development system, but not for you live system. Sometimes only one customer does not receive mails or only a special kind of email is not received or sent. There is a big number of possible problems and also for possible problem sources. Let us try to find your problem and a solution or fix.
Before Magento 1.9.1, mails were sent by action. A simple order mail was sent directly after creation of this order. The mail was created and given to a configured mail program on your host server. You had no chance to see if it was sent or even received. Only one simple flag in sales_flat_(order/invoice/shipment) tables showed you, that something happened. If you PHP process died by sending your mail, a good place to start your research is your server log.
With Magento 1.9.1 things got easier, because Magento puts your mail into a mail queue (a simple table called core_email_queue). Stored mails are sent by cron. With this, you can see, if Magento creates a mail and identify your mail server as problem or not.
A good place to start code debugging is Mage_Core_Model_Email_Template_Mailer. In this core send() method all mails are sent. If it is never called, than you may have a problem. Some plugins overwrite this core class, so you also need to check if a class extends it. If you debug order, invoice or shipping mails, you may end up in sales models. An invoice mail with attached invoice calls sendEmail() from Mage_Sales_Model_Order_Invoice. There are comparable methods for order and shipping.
Mail server logs
Depending on your hoster, you may have access to mail server logs. There you find infos about sent mails or delivery problem error messages. If you can find errors, it is often quite simple to fix a problem, because such messages are helpful. If you have troubles, contact your server administrator. If you get no error, a mail was sent out to target mail server. That does not means, that you customer received it!
A common problem for shop systems is, that order and invoice mails are often detected as spam. There are keywords, that are bad for such filters like “payment”, “credit card number”, and so on. If your mails are lost in spam, you can change your mail texts in your Transaction-Emails. Sometimes minimal changes are the solution.
If your shop or your server was hacked and used by spam bots, your IP address may be black listed as spam server. If this happens, it is difficult to redo this. You need to search for black lists around the net and contact those admins to delete your entry. If you are on a black list, all mails will end in spam folders or even worse, they are filtered and dropped.
I hope you can find your Magento email problem with less effort than me. Sometimes it is really embarrassing and often only a small silly problem.
Tell me about your horror stories of debugging mail problems?