Download the PHP package mspacemedia/silverstripe-newsletter without Composer

On this page you can find all versions of the php package mspacemedia/silverstripe-newsletter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package silverstripe-newsletter

SilverStripe Newsletter

Compose MailChimp-style, drag-and-drop HTML newsletters in the CMS from Elemental blocks, manage CMS-defined audiences, brand them from a central theme, send them in batches over SMTP, and track opens/clicks/bounces using Silverstripe's native CMS preview pane in the editor.

Version: 1.1.0 Requires: SilverStripe 5.4 · PHP 8.1+


Contents


Features


Installation

  1. In the project root composer.json, add the path repository and require it, or via command line:

A default NewsletterBrand record is created automatically on dev/build.

Permissions: everything is gated behind the MANAGE_NEWSLETTERS permission. Grant it to the groups that should manage newsletters (Security → Groups → Roles).


Concepts

Model Role
NewsletterIssue A single newsletter. Holds an Elemental area, targets audiences, carries send status + stats.
NewsletterAudience A mailing list. Subscribers are attached manually, by CSV, or by a source provider.
NewsletterSubscriber A recipient (unique by email). Belongs to many audiences. Status: Active / Unsubscribed / Bounced (global suppression).
NewsletterBrand Global styling tokens (the "theme"). One record per install, editable in the CMS.
NewsletterSendRecord Per-recipient delivery + engagement ledger (sent/failed/bounced, opens, clicks).

All are managed under the Newsletters admin section.


The block library

Issues are composed from Elemental blocks (edited inline). Available blocks:

Header (brand logo, overridable) · Heading · Text · Boxed text · Columns (2–3) · Image · Image + caption · Image group · Image card · Button · Video (links out) · Social follow · Logo · Custom HTML · Divider · Spacer · Footer (address + view-online/unsubscribe links).

Every block has an Appearance tab with per-block overrides — padding, alignment, section style, font family, background colour, text colour, link colour (blank = inherit the brand), full-width edge-to-edge toggle (used by the Image block for full-bleed images), and hide-on-mobile.

Section style bands a block in brand colours without hard-coding them:

Give consecutive blocks the same style to build a banded hero or call-to-action panel.

Block details worth knowing:

The blocks render to email-safe, table-based HTML; CSS is inlined at send time (Emogrifier), and a small-screen media query tightens gutters, stacks columns and steps down large headings. These blocks are restricted to newsletters — they don't appear in normal page editors.


Starter templates

New newsletters needn't start blank. When creating a newsletter, the Start from dropdown pre-fills the content blocks with a ready-made layout; edit everything after the first save. Starters take their look entirely from the brand/theme, so they're on-brand in any install.

The module ships five:

Starter Layout
Monthly update Hero image, lead story, two-column round-up, callout, primary call-to-action band, social, footer
Announcement Primary-colour banner with headline and button, body copy, key-details box, sign-off
Product spotlight Hero image, centred intro, three accent-band benefits, two image cards, offer box
Event invitation Accent banner with date, venue and RSVP, three-step programme, practical details, outline button
Plain letter Logo, a personal letter and signature: reads like a one-to-one email

Placeholder images ("Replace with your image") are imported once into assets/newsletter/starters/ and shared by every starter that uses them. Starter copy uses {{ FirstName | default('there') }}-style merge fields, and starter footers are left blank so they show the brand's footer text.

Saved templates. Tick Use as a template on any newsletter to offer its blocks in Start from as Saved template: …. Templates can be test-sent but never sent to audiences. A layout is only ever applied to an empty newsletter.

Adding starters (host projects). Define them in YAML; type is a block short name or class, image a file in this module's client/dist/starters/, and every other key a block field:

Config merges list values, so redefine a shipped starter under a new key rather than editing its blocks.


Branding / theme

NewsletterBrand holds the global look: font family, heading weight, primary/link/ heading/body colours, page + content background, accent background and text-on-primary colour (for section styles), content width, button colour/text/radius/padding, divider colour, footer colour and footer text, and a header logo.


Audiences, subscribers & CSV import/export

Subscribers carry name/email plus arbitrary merge data (custom JSON keys). These personalise content through the {{ … }} merge-field engine — e.g. {{ FirstName }}, {{ Email }}, and any custom key as {{ MYKEY }}. Unsubscribe and view-online links are provided by the Footer block.

Personalisation resolves late: a live send stores the rendered issue HTML before recipient-specific values are substituted, then each delivery (and recipient-specific view-online request) resolves the merge fields for that subscriber.


Dynamic audiences (source providers)

A host project can feed an audience from its own data by implementing MSpaceMedia\Newsletter\Source\AudienceSourceProvider:

Each yielded row:

Register providers in config and run the refresh task:

The task upserts subscribers (deduped by email) into the matching audience, refreshes name/merge data, links the optional Anchor, and never re-activates unsubscribed/bounced records. Audiences with no provider are simply manual/CSV-only.

Returning an Anchor (any DataObject, typically the project's Member) is what lights up the computed merge fields below — it stores the polymorphic NewsletterSubscriber.Anchor that {{ … }} expressions traverse. A provider that builds an audience from members therefore needs nothing extra:

Subscription API (for project glue such as account pages / checkout): MSpaceMedia\Newsletter\Service\NewsletterSubscriptionManager provides subscribe($email, $audienceKey, $data), unsubscribe($email), bounce($email) and isSubscribed($email). The $data array also accepts an 'Anchor' => $record to link the subscriber for computed merge fields. unsubscribe() fires an onNewsletterUnsubscribe extension hook so a project can reflect the change back onto its own models.


Computed merge fields

Editors personalise content with {{ … }} merge fields — both simple values ({{ FirstName }}) and computed fields that derive a value per recipient from the project's own data: totals, counts, filtered aggregates, with maths and conditionals. The drag-and-drop-friendly equivalent of MailChimp's merge tags.

Examples:

The anchor

Every computed field traverses from the subscriber's anchor — a record linked via the polymorphic NewsletterSubscriber.Anchor (set by a source provider or the subscription manager, above). The anchor is usually a Member; configure its type so the visual builder knows what to introspect:

A subscriber with no anchor isn't an error: every computed field resolves to empty, so | default(…) and {{#if}} fallbacks take over (e.g. "no orders placed").

Defining a field

Create fields under Newsletters → Merge fields. Each has a Tag (used as {{ TAG }}) and an Expression. The expression editor offers relation/field pickers and a live preview that evaluates against a random sample record — so you build the output visually and see a real value as you go. A defined tag can be referenced from other expressions, and tags resolve in this order: defined field → built-in (FirstName, Surname, Email, plus the subscriber's custom merge data) → a field/relation on the anchor.

Expression language

Construct Example Notes
Field FirstName Built-in or an anchor field
Relation count Orders.Count has_many / many_many
Aggregate Orders.Sum(Amount) also Avg / Min / Max
Filtered Orders.Where(Status = 'Paid').Sum(Amount) =, !=, >, <, >=, <=
Maths Orders.Sum(Amount) / Orders.Count + - * /, parentheses
Functions Concat(...), Select(cond, a, b), Coalesce(a, b), Round(x, 2), Upper, Lower inline value picker is Select (If is a legacy alias)
Filters (pipe) … \| currency, … \| number(2), … \| default('n/a'), … \| date('d/m/Y')
Conditional block {{#if expr}}…{{else}}…{{/if}} nestable

The table above is the common subset; the complete expression-language reference lists every literal, operator, aggregate (incl. First), function, filter, built-in tag, and the resolution/truthiness rules.

Exposing data (required) — the allowlist

The engine is default-deny: it can only traverse relations/fields a project has explicitly exposed. Nothing resolves until you opt in, which also keeps editors away from sensitive fields (password hashes, tokens, …):

Entries on a parent class cover its subclasses. The visual builder only offers allowlisted paths, and the evaluator re-checks the same list at send time — the UI is a convenience, never the security boundary. Aggregates and Where() run as parameterised ORM queries (no eval, no raw SQL), and a broken or unauthorised tag renders empty rather than leaking an error into the email.

When it resolves

Computed fields resolve per recipient at send time — so the locked sent snapshot stays generic and each delivery (and recipient-specific view-online page) personalises from it. They are left as literal {{ … }} in the snapshot.


Audience segments

The same expression engine powers segments: an audience can define a boolean expression that selects active subscribers into itself. A segment is therefore just a normal audience, so issues target it like any other — no special send path.

Any audience can become a segment by setting a Segment expression (Segment tab). It's evaluated per subscriber against their anchor, and a truthy result includes them:

Subscribers with no anchor, and suppressed (unsubscribed/bounced) subscribers, are never matched.

Performance

Membership is evaluated row-by-row (one pass over active subscribers), which is fine for periodic rebuilds. For the common Relation.Count|Sum|Avg|Min|Max <op> number shape (with >, >= or =) the service instead runs a single grouped query, avoiding a query per subscriber on large lists; results are identical to the row-by-row path. Anything more complex (Where(), maths, functions, many-to-many relations) uses the row-by-row evaluator.

Security

Identical to computed fields: only allowlisted relations/fields are traversable, via parameterised queries.


Sending

Open an issue, compose it, choose its audience(s) and brand, then use the buttons in the CMS:

When a live send starts, the issue is locked:

CLI equivalent:

SMTP transport is the project's SS_MAILER_DSN. In dev, use a catcher / the send_all_emails_to safety net so tests never reach real recipients.


Tracking (opens & clicks)

Open tracking is best-effort (image-blocking inflates "not opened"); clicks are the firmer signal.


Bounce handling

Phase-1, webhook-free. Pipe bounce DSNs (from a bounces@ forwarder) to the task:

Each send carries an X-Newsletter-Token header; the task correlates the bounce back to its NewsletterSendRecord (falling back to the Final-Recipient address), marks the record Bounced with the diagnostic reason, and globally suppresses the subscriber. processRaw(string $raw): bool is public so a future IMAP/POP poller can reuse the parsing.

Requires a mail-forwarder rule and proc_open on the host.


Preview

Newsletter issues use Silverstripe's native CMSPreviewable support inside NewsletterAdmin, so the preview appears in the standard CMS preview pane rather than a custom floating panel. The built-in Silverstripe preview controls, including device switching, remain available.

Preview rendering is handled by two ModelAdmin actions:

Preview as a subscriber

A toolbar at the top of the preview lets you render the issue as a real subscriber — like MailChimp's "Preview as subscriber". cmsPreview accepts ?previewSubscriber=random (or a subscriber ID), draws from the issue's recipients (falling back to any active subscriber), and renders through renderEmail($issue, $subscriber) so {{ … }} merge fields are resolved for that person (tracking pixels/links are omitted in preview). The toolbar's Another / No personalisation links simply reload the iframe — no parent-frame scripting.

client/dist/newsletter-preview.js only coordinates the native preview:

Sent issues render from the locked SentHTML snapshot when available, so the preview and public view-online pages reflect the sent content rather than later edits.


Routes

Route Purpose
newsletter/view/<token> Public "view online" page for an issue; uses the sent snapshot when present.
newsletter/viewrecord/<token> Recipient-specific "view online" page for a send record; resolves merge tags for that subscriber.
newsletter/unsubscribe/<token> One-click unsubscribe (per-subscriber token).
newsletter/open/<token>.png Open-tracking pixel.
newsletter/click/<token>?u=<url> Click redirector.
newsletter/preview/<issueID> Legacy/admin preview route; native CMS preview uses NewsletterAdmin cmsPreview actions.

Layout


Out of scope (v0.1)


All versions of silverstripe-newsletter with dependencies

PHP Build Version
Package Version
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mspacemedia/silverstripe-newsletter contains the following files

Loading the files please wait ...