Sendouts & Automation
A Sendout (campaign-sendout) binds a Campaign to a target audience (one or more Mailing Lists, a Dynamic Segment, or an explicit recipient) and governs how and when messages are dispatched. Separating campaigns from sendouts lets you reuse the same campaign template across multiple dispatches, recurring digests, or automated welcome sequences while keeping per-sendout analytics isolated.
The 5 Sendout Types
Section titled “The 5 Sendout Types”| Type | Use Case | Dispatch Mechanism |
|---|---|---|
regular |
One-time newsletter or broadcast sent immediately. | Triggered manually via Send Now, $campaign->sendNow(), or campaign:send --sendout=<uuid>. |
scheduled |
One-time broadcast queued for a future UTC date and time. | Picked up automatically by ProcessScheduledSendoutsTask (or campaign:send --due) when scheduled_at <= now. |
automated |
Event-driven drip or transactional marketing emails. | Fired automatically by AutomationEngine when one of the 5 supported triggers occurs. |
recurring |
Periodic digests (weekly newsletter, monthly fleet summary). | Calculated by RecurrenceCalculator (daily, weekly, monthly, or custom UTC 5-field cron expression) and spawned on schedule. |
singular |
Targeted one-off message to a single contact (VIP outreach, follow-up). | Dispatched directly to a specific contact UUID or email without requiring a mailing list. |
Sendout Lifecycle & Queue Batching
Section titled “Sendout Lifecycle & Queue Batching”flowchart LR Draft["Draft"] --> Scheduled["Scheduled / Active"] Scheduled --> Queued["Queued (Recipients Materialized)"] Queued --> Sending["Sending (ProcessSendoutBatchQueue)"] Sending --> Completed["Completed"] Sending --> Paused["Paused / Cancelled"] Scheduled --> Cancelled["Cancelled"]
When a sendout starts:
- Audience materialization:
CampaignDispatcherresolves active subscribers from the selected Mailing Lists and/orSegmentEvaluator, deduplicates by normalized email, and excludes any address present incampaign_suppressions. - Recipient rows: Each eligible recipient is written to
campaign_sendout_recipientsinpendingstate with a unique recipient token. - Batch execution:
ProcessSendoutBatchQueueclaims batches sized bybatch_size(default50), respectsthrottle_per_minute, renders personalized HTML/plaintext viaCampaignRenderer, and sends viaWireMail. - Retry & dead-letter handling: Transient transport failures are retried up to
max_send_retrieswith exponential backoff before marking the recipient rowfailedand recording the diagnostic error.
Automated Sendout Triggers
Section titled “Automated Sendout Triggers”AutomationEngine listens to ProcessWire and sibling module events and supports five trigger types:
| Trigger Key | When It Fires | Common Example |
|---|---|---|
list_subscribed |
Immediately after a contact confirms Double Opt-In (or is admin-confirmed) on a target mailing list. | Send a welcome guide when someone joins aegean-voyages. |
contact_created |
When a new contact record is created in Contacts. |
Send a first-touch brand introduction email. |
user_registered |
When a new ProcessWire user or Account member registers. |
Send an onboarding checklist to new portal accounts. |
form_submitted |
When a Forms submission completes (optionally filtered by form handle). |
Send a charter brochure after a quote request form is submitted. |
contact_date_field |
Daily check against a date field on Contacts (such as birthday, renewal date, or departure anniversary). |
Send an annual loyalty offer 7 days before a guest’s charter anniversary. |
Automated sendouts support optional delay offsets (for example, send 2 hours or 3 days after the trigger event) and per-contact deduplication so the same contact does not receive duplicate automated messages.
Recurring Schedules (RecurrenceCalculator)
Section titled “Recurring Schedules (RecurrenceCalculator)”Recurring sendouts calculate their next UTC execution timestamp using RecurrenceCalculator:
daily: Runs once per day at the configured UTC hour and minute.weekly: Runs on the configured day of week and UTC time.monthly: Runs on the configured day of month (clamped safely for short months) and UTC time.- Custom UTC Cron: Accepts standard 5-field cron expressions (for example,
0 9 * * 1,4for Mondays and Thursdays at 09:00 UTC).
Scheduled Tasks & Maintenance
Section titled “Scheduled Tasks & Maintenance”Campaign ships two processwire-console scheduled tasks:
ProcessScheduledSendoutsTask: Evaluates duescheduledsendouts, triggersrecurringdispatches whose next run window has arrived, processescontact_date_fieldautomations, and releases delayed automation queue items.PruneCampaignDataTask: Enforces theevent_retention_dayspolicy fromCampaignSettingsby pruning or anonymizing expired tracking rows incampaign_eventsand old recipient metadata.
Dispatching Sendouts Programmatically
Section titled “Dispatching Sendouts Programmatically”<?phpdeclare(strict_types=1);
namespace ProcessWire;
$campaign = \Totoglu\Campaign\Campaign::requireInstance($wire);$sendout = $wire->entries->findOne('type=campaign-sendout, name=summer-2026-launch');
if ($sendout !== null) { // Dispatch immediately (queues ProcessSendoutBatchQueue batches) $campaign->sendNow($sendout);
// Or schedule for a future UTC timestamp $campaign->scheduleSendout($sendout, '2026-06-15 08:00:00');}