I am sent an email when an order is placed, but there is speed issue. Can you advise me how to add a custom email to the queue when an order is placed?

try {
        $mail = Mage::getModel('core/email');
        $mail->setSubject("Automated Bundle Purchase: Coupon Code");
    } catch (Exception $e) { 

1 Answer 1


When the message is queued, the email data is saved in the Magento database where it will be later fetched and an email message will be reconstructed from the data and sent. The data is stored in two new tables, one for the email data and one for the recipients:


When and how is the queue cleared ?

    <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
    <schedule><cron_expr>0 0 * * *</cron_expr></schedule>

That means the send() function on the queue will be called every minute and the clean up once per day at midnight 00:00.

So you can reference you to this one :

if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {
    /** @var $emailQueue Mage_Core_Model_Email_Queue */
    $emailQueue = $this->getQueue();
            'subject'           => $subject,
            'return_path_email' => $returnPathEmail,
            'is_plain'          => $this->isPlain(),
            'from_email'        => $this->getSenderEmail(),
            'from_name'         => $this->getSenderName(),
            'reply_to'          => $this->getMail()->getReplyTo(),
            'return_to'         => $this->getMail()->getReturnPath(),
        ->addRecipients($emails, $names, Mage_Core_Model_Email_Queue::EMAIL_TYPE_TO)
        ->addRecipients($this->_bccEmails, array(), Mage_Core_Model_Email_Queue::EMAIL_TYPE_BCC);

    return true;


EDIT: Try to add this before send():

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

  • This all is accepted. But how we can add custom email on that queue table. You sent me mechanism. But how we can add an entry of mail in that queue table? Commented Jul 20, 2017 at 9:44
  • You create your custom module custom email based on Mage_Core_Model_Email_Template => sendTransactional, Mage_Core_Model_Email_Queue I don't see what is complicated. Look my Edit
    – PЯINCƎ
    Commented Jul 20, 2017 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.