Delivering Emails by Queue and Troubleshooting Magento Emails Not Sending Issue

Delivering Emails by Queue and Troubleshooting Magento Emails Not Sending Issue

Categories E-commerce | Magento

While planning to set up an email campaign with Magento, it will require an outgoing server like SMTP to take care of messages delivery.

You may encounter delivery problems on configuring Magento with a normal SMTP server, same as one linked to Hotmail or Gmail;

  • Magento sends multiple event emails for every section event after registering with Magento community store.
  • Two order confirmation emails are received from Magento store after doing the order.
  • Any activity running via CRON performs its actions twice.
  • Customers may not receive order confirmation email. 

magento-extensions

Before proceeding further to discuss troubleshooting ‘Magento emails not sending’ issues, let us first know about the respective SMTP setting with Magento to deliver email templates.

How to Deliver emails with Magento?

Procedure for SMTP setting with Magento:

  1. On logging in to Magento select, System-> Configuration-> Advanced-> System-> Mail Sending Settings.

  2. Now enter the preferred SMTP server name (or select from drop down list of the major ones) and SMTP port (i.e. 25 as default, we can also select other options as well).

  3. Select and copy local file app/code/core/Mage/core/Model/Email/Template.php.

  4. Then Enable this module.

  5. Finally, open the Template.php file and change the getMail() function as shown:

public function getMail()

{
if (is_null($this->_mail)) {
/* changes begin */
$my_smtp_host = Mage::getStoreConfig('system/smtp/host');
$my_smtp_port = Mage::getStoreConfig('system/smtp/port');
$config = array(
'port' => $my_smtp_port, 'auth' => 'login',
'username' => '[email protected]',
'password' => 'yourpassword' );
$transport = new Zend_Mail_Transport_Smtp($my_smtp_host, $config);
Zend_Mail::setDefaultTransport($transport);
/* Changes End */
$this->_mail = new Zend_Mail('utf-8');
}
return $this->_mail;
}

Now get ready to deliver emails with Magento.

How to Deliver Default Emails by Queue In Magento 1.9.1 ?

The email handling will be repaired on updating Magento site to the latest version 1.9.1. Now these emails will become responsive on a mobile device. Importantly all emails including transactional emails are being sent via CRON job. So, while facing problems abruptly with Magento emails not being received by your customers, you just need to check or set up on CRON job on a respective server for its proper working.

smile-oss-magento-expertise-27-638

All Magento email sending comes with template Mage_Core_Model_Email_Template.

If no queue is seen, then the send() function proceeds to build the mail object for sending.

At this point, SMTP Pro and MageSend extensions connected to the Template class will apply their transport to change the mail transport.

If you still encounter delivery problems in Magento, you can just put up your query on the contact page or consider to Hire Magento Developer from us to optimize this email module issue for your e-store.

How to check all emails actually being queued?

When the email is queued, all the emails data is generally saved in the Magento database in two new tables, one for the recipients and second for email data (as shown). This data can be later recovered to reconstruct any email message and sent.

core_email_queue

 

core_email_queue_recipients

 

Magento have inbuilt two new CRON jobs to check how and when is the queue cleared, as shown below:

*/1 * * * *

core/email_queue::send

0 0 * * *

core/email_queue::cleanQueue

</core_email_queue_clean_up>

So, it can be concluded from above script that on the queue, send() function will be called every minute and clean up one time per day at 00:00 midnight. Out of the emails data table, a lump of MESSAGES_LIMIT_PER_CRON_RUN (default 100) emails size will be seized by the send() function and one by one send queued emails.

$collection = Mage::getModel('core/email_queue')->getCollection()

->addOnlyForSendingFilter()

->setPageSize(self::MESSAGES_LIMIT_PER_CRON_RUN)

->setCurPage(1)

->load();

How to use CRON to send Magento Emails?

CRON jobs (Mage_Cron) are already set as default by Magento. This can be found out by checking System-> Advanced → Cron (as Scheduled Tasks).

It is quite easy to enable and investigate CRON job in a server. Locate the “CRON jobs” section on to hosting cPanel. After finding it, check for a CRON job on your server and create one if not present. Then set the desired intervals for emails queue.

Important to note, that using an absolute path direct your server to the cron.php in its Magento root (as shown) :

cron-php-path-server

You can also include Magento extension to monitor all SMTP server scheduled tasks for a complete peace of mind. The best example for this is to set up SMTP Pro Email which is easy to install via Magento-connect or manually via Github.

Note: For any of issues related to CRON set up can be checked here this wiki article

Troubleshooting Magento Email Not Sending Issues!

If you want to see whether your email was sent or not, then the best way is to check the information area beside the order number.

Sending-emails-e1361177764262

If you are not receiving the email, even after the order displays the email as sent, then the most likely the problem resides in the Magento email settings or an email server used by Magento. First look through settings, whether it is turned on or not.

    • Check Admin -> Configuration > Advanced -> System > SMTP Settings and ensure that your emails are not disabled.
    • Check Admin -> Configuration > General > Store Email Addresses and see there for the correct email addresses. An improper email address may be refused to send email by the email servers.
    • Check for any extension used by Magento for sending the emails. Within your root Magento directory, run the php script on port 587 to find feasibility to connect ‘smtp.gmail.com’. This port can be conveniently replaced with other ports to test access. Consult your serving company to resolve the issue, if still getting an error.
    • Check System => Configuration => Sales Emails => Shipment Comments to In a Magento admin, look for the email sending is enabled for dispatches.
    • Usually local PHP or SMTP mail servers are used by Magento to send out the emails. Sometimes inside Magento, emails might be structured in the way that they are not sent and get refused by the server.
    • Check the server to see whether it is supporting the email sending or not, if Magento is not using any extension to send the emails.
    • After checking all above issues, you can check over the exception logs and error ({Magento root}/var/logs/). Check for any order related errors, warnings or mail. The logs should provide you an indication for any problem.
    • Next important log may be your server’s mail log, which can at-least show you if any email has been sent from the server. This can be checked at /var/log/maillog depending on your mail software and OS.
    • Sometimes, emails may fail to reach the World Wide Web, even it has been sent to the test account which is directed on the server to one of the users. In this instance, to handle the emails, cPanel is used by the server and moreover, on the server a local MX record is also created when the test email domain account has been created.
    • Regardless of the email address, the MX record guides the email server to send it to the server’s local user. It is very easy to fix this local redirect. Within the domain, simply edit the local MX record to the domain of Google Gmail apps.
    • It should be ensured that Magento server is properly installed and configured correctly for emails as per needs.Following all above procedures, you can troubleshoot other reasons for which the clients are not receiving email.

 

We are discussing one of the major issue related to Magento emails not sending issue and its troubleshooting:

 

Problem
    • Magento sends multiple event mails for every section event, like if a customer register on Magento community store, then customer get two mails regarding account confirmation.
    • If any customer do the order, then two order confirmation emails are received from Magento store.
    • Any activity running via CRON performs its actions twice.
Analysis :
    • Magento works with CRON/action event or overriding of action/event function. Also, both core/override function run under this action. So, this problem may arise due to continuous running of your core function method as well as override function method.
    • As per debugging, the above problem comes with Magento community version 1.9.2.1. But it is not specific and it may come under lower Magento versions also.
Solution
      1. Added SMTP pro Extension

Finally, our issue is resolved and now we are receiving one e-mail per order with following Magento SMTP Pro Extension entries:

Screen Shot


If you are also facing the issue related to the above mentioned Magento Email not Sending, then at TBI our experienced Magento experts can guide and help you to troubleshoot annoying issue related to Magento emails not sending.

Also, if you have any query or issue related to Magento emails server extension, then The Brihaspati Infotech will be readily available to guide and serve you at par to your needs.

To learn more about Magento and its related information you may visit our blog section Magento.

We oblige you to share your comment or suggestion with us, on Reaching Us. You can also email us at [email protected]. It would be our pleasure to contact you soon.