Skip to content

Lists & Subscriptions

Campaign separates contact identity (Contacts module) from mailing-list consent (campaign_subscriptions SQL table). A single contact can subscribe to multiple mailing lists independently, with per-list Double Opt-In timestamps, IP/user-agent proof, and unsubscribe state.

Open Setup > Campaigns > Mailing Lists to create and configure lists.

Mailing Lists control Double Opt-In enforcement, public visibility in the preference center, and automatic ProcessWire role syncing.

Key fields on each Mailing List entry:

  • title & handle: Human-readable name and stable machine handle (for example, aegean-voyages).
  • double_opt_in: When enabled, new public subscriptions start in pending state and receive a confirmation email containing a signed /_campaign/confirm/{token} link.
  • is_public: Controls whether the list appears on the subscriber self-service preference center (/_campaign/preferences/{token}).
  • sync_user_roles: Optional ProcessWire role names (such as vip-member or crew-partner). Running role sync subscribes matching active ProcessWire users automatically and unsubscribes users who lose the role.
  • confirm_redirect_url & unsubscribe_redirect_url: Optional landing URLs after confirmation or unsubscribe actions.

Navigate to Setup > Campaigns > Subscribers to inspect active, pending, unsubscribed, and bounced/complained memberships across all lists or a single filtered list.

The Subscribers workspace provides KPI cards, quick manual subscription, CSV import/export, and per-row status management.
Status Meaning Eligible for Sendouts?
pending Submitted via public form; awaiting Double Opt-In confirmation click. No
subscribed Confirmed active subscriber (or admin-confirmed). Yes (unless globally suppressed)
unsubscribed Opted out via one-click link, preference center, admin, or API. No
bounced Hard-bounced or exceeded soft_bounce_threshold. No
complained Reported spam via ESP feedback loop webhook. No

Double Opt-In, RFC 8058 One-Click Unsubscribe & Preference Center

Section titled “Double Opt-In, RFC 8058 One-Click Unsubscribe & Preference Center”

Campaign serves complete public compliance endpoints under your configured public_route_prefix (default /_campaign):

  • Double Opt-In (GET|POST /_campaign/confirm/{token}): Validates the HMAC-signed token, transitions the subscription from pending to subscribed, records confirmed_at, and fires Campaign::afterSubscribe (which also triggers list_subscribed automated sendouts).
  • One-Click Unsubscribe (GET|POST /_campaign/unsubscribe/{token}): Every outgoing email includes RFC 8058 headers (List-Unsubscribe and List-Unsubscribe-Post: List-Unsubscribe=One-Click). Mail clients sending an automated POST immediately unsubscribe the recipient without requiring a confirmation click; browser GET visits render a clean confirmation view.
  • Preference Center (GET|POST /_campaign/preferences/{token}): Lets subscribers toggle membership across all is_public = true mailing lists or opt out globally in one step.

Frontend Subscribe Form (renderSubscribeForm)

Section titled “Frontend Subscribe Form (renderSubscribeForm)”

Render a ready-to-use, CSRF-protected subscribe form in any ProcessWire template with honeypot spam trapping, signed timestamp verification, and CampaignRateLimiter throttling:

<?php
declare(strict_types=1);
namespace ProcessWire;
$campaign = \Totoglu\Campaign\Campaign::requireInstance($wire);
echo $campaign->renderSubscribeForm('aegean-voyages', [
'show_name' => true,
'button_label' => __('Join Aegean Voyages Dispatch', __FILE__),
'redirect' => $page->url . '?subscribed=1',
]);

Submissions post to POST /_campaign/subscribe, validate the CSRF token, check the honeypot field and minimum submission dwell time, enforce per-IP and per-email rate limits, upsert the contact in Contacts, and either confirm immediately or dispatch the Double Opt-In email.

<?php
declare(strict_types=1);
namespace ProcessWire;
$campaign = \Totoglu\Campaign\Campaign::requireInstance($wire);
// Subscribe with Double Opt-In (default respects list setting)
$result = $campaign->subscribe('[email protected]', 'aegean-voyages', [
'first_name' => 'Elena',
'last_name' => 'Lindholm',
'source' => 'booking_checkout',
'confirm' => false, // set true to confirm immediately
]);
// Confirm via token
$campaign->confirmDoubleOptIn($token);
// Unsubscribe from a specific list (or pass null for all lists)
$campaign->unsubscribe('[email protected]', 'aegean-voyages', 'user_request');

You can import and export subscribers from Setup > Campaigns > Subscribers or from the CLI:

  • CSV Import (TransferService / campaign:import): Accepts UTF-8 CSV files with email (required) plus optional first_name, last_name, company_name, country_code, preferred_language, and tags columns. Invalid emails and globally suppressed addresses are skipped and reported in the summary.
  • CSV Export (TransferService::writeSubscribersCsv() / campaign:export): Streams formula-injection-safe CSV output filtered by mailing list and subscription status (all, subscribed, pending, unsubscribed, bounced, complained).
Terminal window
# Dry-run an import first
php vendor/bin/wire campaign:import --list=aegean-voyages --file=guests.csv --confirm --dry-run --json
# Export all active subscribers
php vendor/bin/wire campaign:export --list=aegean-voyages --status=subscribed --output-file=active-guests.csv --json

When a mailing list specifies one or more sync_user_roles, click Sync Roles in the workspace or run campaign:sync-roles:

Terminal window
php vendor/bin/wire campaign:sync-roles --list=aegean-voyages --json

For large user bases, ProcessCampaign dispatches SyncUserRolesQueue in the background so admin requests return immediately.

Next steps