Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A CakePHP plugin that makes it easy to queue emails in the database rather than sending them out right away. Great for mass emails.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
controllers Allowing QueueEmailComponent::interpret to accept more complex data

This plugin is deprecated and no longer maintained in favor of more robust solutions, such as proper job queuing plugins like CakeResque.


QueueEmail is a CakePHP plugin that allows you to queue emails in your database instead of sending them directly out. This is helpful for sending large batches of emails via a CRON job.


Create the table

cake schema create QueueEmail.queue

Use the QueueEmail component

var $components = array('QueueEmail.QueueEmail');

Then send your emails as you normally would

$this->QueueEmail->to = '';
$this->QueueEmail->from = '';
$this->QueueEmail->subject = 'A queued Email';

Instead of sending, the email will be stored in the database. You can do anything you would do on the built-in Email component with QueueEmail, such as sending via smtp, attaching files, etc.

When you're ready to send, use the shell provided. I recommend setting up a CRON job to execute the shell every 5 minutes.

/path/to/site/cake/console/cake -app "/path/to/site/app" queue_sender send

You can also send individual emails by passing the id directly after the send method:

/path/to/site/cake/console/cake -app "/path/to/site/app" queue_sender send 12

If you have emails you don't want to queue, simply change the $queue var to false.

$this->QueueEmail->queue = false; // this email won't be queued

This will send the email as the regular EmailComponent normally would.


The shell supports several options, described below. You can pass them directly via the CLI, or by setting its value in the Configure class.

  • batchSize Limit the number of queued emails sent at time. Default 50.
  • maxTries Limit the number of send attempts. Default 5.
  • deleteAfter Remove the record from the db after it sends successfully. Default true.

Setting using the shell:

/path/to/site/cake/console/cake -app "/path/to/site/app" queue_sender send -batchSize 100

Setting using Configure:

Configure::write('QueueEmail.batchSize', 100);


The QueueEmail plugin also comes with some limited views that allow you to see what emails are currently queued. Visit /queue_email/queues/index


Much of the information is stored as serialized array strings and I'm not fond of that. If you have suggestions to avoid this let me know.


  • Add ability to send one or multiple emails from the management console.


Licensed under The MIT License Redistributions of files must retain the above copyright notice.

Something went wrong with that request. Please try again.