We have over 100,000 customers that meet certain criteria (such as last login date) that need to be sent an email. This is NOT a newsletter as these recipients may not be subscribed to our newsletter. I can send an email easily enough to each customer one at a time in a foreach loop using the following code:

$emailTemplate->send($vars['email'], $vars['email'], $vars);

However, I didn't know if using Magento's 1.9's email queue would be a better to avoid spam issues and be less resource draining manner in which to send these emails. Is that the right approach or is there a better way?

I am aware of how Magento sends through the queue order confirmation emails using the following code:

    /** @var $emailQueue Mage_Core_Model_Email_Queue */
    $emailQueue = Mage::getModel('core/email_queue');


Being a novice and somewhat new to the development side of Magento, I am struggling with the right approach to creating my own email, that is not a transaction email, but a mass email sent to specific customers (not necessarily signed up for a newsletter either).

Trying to trace the setEntityId method along with the setEntityType and setEventType, I found the following (which wasn't helpful at all) located in app/code/core/Mage/Core/Model/Email/Queue.php:

    * Email Template Mailer Model
    * @method Mage_Core_Model_Email_Queue setEntityId(int $value)
    * @method Mage_Core_Model_Email_Queue setEntityType(string $value)
    * @method Mage_Core_Model_Email_Queue setEventType(string $value)
    * @method Mage_Core_Model_Email_Queue setIsForceCheck(int $value)
    * @method int getIsForceCheck()
    * @method int getEntityId()
    * @method string getEntityType()
    * @method string getEventType()
    * @method string getMessageBodyHash()
    * @method string getMessageBody()
    * @method Mage_Core_Model_Email_Queue setMessageBody(string $value)
    * @method Mage_Core_Model_Email_Queue setMessageParameters(array $value)
    * @method Mage_Core_Model_Email_Queue setProcessedAt(string $value)
    * @method array getMessageParameters()
    * @category    Mage
    * @package     Mage_Core

There is nothing else in Queue.php to hint at or explain what these methods are for and how to use them for my own purposes. The setEntityId hints at the emails stored in the mgt_core_email_templates table along with the EntityType, except when looking at that table, the ID is template_id, not entity_id, and the type is template_type not entity_type. The EventType completely confounds me in this case.

What I need is the following:

  1. Is my approach correct? Is there best practices in sending out mass emails that won't fall into some sort of spam black hole?
  2. How do I php programmatically add 100,000+ recipients to the email queue?
  3. Where is the email actually built? In the Admin database or in app/locale/en_us/template/email/...?

Any help would be greatly appreciated! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.