Skip to content

Sending Queued Emails

objectivehtml edited this page Dec 12, 2014 · 14 revisions

Overview

Postmaster has the ability to send anything in the future. For example, once your parcel(s) is configured to send messages in the future, you are going to need to send them. Postmaster makes sending items from the queue at the right time real easy. There are two ways to it:

CRON Job

The easiest option is to setup a CRON job that sends an HTTP request at a frequent interval. For active queues, you may need to send a request every 5 minutes. Other sites with low traffic may only need to do so once an hour. The interval at which you ping the queue is completely up to you.

//yoursite.com/postmaster/queue/marshal

Anytime a request is sent to that URL, Postmaster will check to see if any items in the queue need to be sent. If there are no items in the queue that need to be sent, nothing will happen.

Queue API

If you need to programmatically trigger the queue you can do so using the following method:

craft()->postmaster_queue->marshal()

Queues aren't limited to just being used by Parcels. Developers can make use of this programmatically and sending their own items to the queue using the following method:

craft()->postmaster->sendToQueue($transportModel)

Note, you must pass a Postmaster_TransportModel object to the sendToQueue() method.