Magento – Magento 1.9.1 – Emails being sent by the new email queue

emailqueue

According to the Magento 1.9.1 release notes:

all Magento e-mails (including order confirmation and transactional) are now queued

However, I cannot see how any emails except the new order and order update emails are being queued.

In this answer you can see the only two places that appear to use the queue.

Am I missing something obvious that would have the queue instantiated for emails such as the contact form POST in Mage_Contacts_IndexController?

I cannot see anything, which makes me think the release notes are wrong, someone please show me the error of my ways?

Best Answer

I tested it on clean Magento 1.9.0.1 installation without setup cron job and it sent me a contact email. So it's not queue contact emails. And if you look at the code you will see the same:

Mage_Contacts_IndexController -> public function postAction() -> sendTransactional which calls:

Mage_Core_Model_Email_Template -> public function sendTransactional -> public function send -> $mail->send();.

On deeper level it calls Zend_Mail -> public function send -> $transport->send($this); -> Zend_Mail_Transport_Abstract -> public function send -> $this->_sendMail(); -> Zend_Mail_Transport_Sendmail -> public function _sendMail() which finally calls directly PHP mail() function:

    $result = mail(
        $this->recipients,
        $this->_mail->getSubject(),
        $this->body,
        $this->header);

In Magento 1.9.1.0 it's added

if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {
...
$emailQueue->addMessageToQueue();

in Mage_Core_Model_Email_Template -> public function send which should be set in public function sendTransactional:

        if (is_numeric($templateId)) {
            $queue = $this->getQueue();
            $this->load($templateId);
            $this->setQueue($queue);
        }

but $templateId should be equal to contacts_email_email_template (by default) so it's not numeric. But if custom email template is chosen it will be numeric so maybe then the email will be queued but I didn't test it.