Skip to content

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.

Sendouts track dispatch type, lifecycle state, linked campaign, targeted count, and delivered count.
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.
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:

  1. Audience materialization: CampaignDispatcher resolves active subscribers from the selected Mailing Lists and/or SegmentEvaluator, deduplicates by normalized email, and excludes any address present in campaign_suppressions.
  2. Recipient rows: Each eligible recipient is written to campaign_sendout_recipients in pending state with a unique recipient token.
  3. Batch execution: ProcessSendoutBatchQueue claims batches sized by batch_size (default 50), respects throttle_per_minute, renders personalized HTML/plaintext via CampaignRenderer, and sends via WireMail.
  4. Retry & dead-letter handling: Transient transport failures are retried up to max_send_retries with exponential backoff before marking the recipient row failed and recording the diagnostic error.

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,4 for Mondays and Thursdays at 09:00 UTC).

Campaign ships two processwire-console scheduled tasks:

  • ProcessScheduledSendoutsTask: Evaluates due scheduled sendouts, triggers recurring dispatches whose next run window has arrived, processes contact_date_field automations, and releases delayed automation queue items.
  • PruneCampaignDataTask: Enforces the event_retention_days policy from CampaignSettings by pruning or anonymizing expired tracking rows in campaign_events and old recipient metadata.
<?php
declare(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');
}

Next steps