Search by

itzbund / gsb-newsletter

GSB11

Newsletter extension for the Goverment Site Build (GSB) 11. This is part of the Government Site Builder (GSB) 11. The GSB 11 is a measure of the Dienstekonsolidierung Bund (DKB) of the Federal Ministry of the Interior and for Homeland (BMI) and is carried out on behalf of the Information Technology

Package info

gitlab.opencode.de/bmi/government-site-builder-11/extensions/gsb_newsletter

Type:typo3-cms-extension

pkg:composer/itzbund/gsb-newsletter

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

v1.12.0-beta.29 2026-12-03 10:34 UTC

This package is auto-updated.

Last update: 2026-12-03 19:21:22 UTC


README

GSB 11 Extension gsb_newsletter

TYPO3 13

About

This extension handles newsletter subscription, unsubscription, and sending via Listmonk (HTTP/JSON API).

Installation

The best way to install this extension is to start with the GSB Sitepackage Kickstarter extension.

For a self-hosted Listmonk setup, follow this order:

  1. Environment variables
  2. Install Listmonk
  3. Configure Listmonk

Listmonk (self-hosting)

When you self-host GSB, Listmonk is the newsletter backend. TYPO3 talks to Listmonk over its HTTP/JSON API. Listmonk must be reachable from the TYPO3 application (typically on the same Docker/Kubernetes network); it does not need to be publicly exposed.

Official Listmonk docs: Installation, API.

Environment variables

Set these variables for the TYPO3 process. They are used by the Listmonk upgrade wizards and for admin-level API access.

VariableRequiredDescription
GSB_NEWSLETTER_HOSTyesHostname or URL of the Listmonk service as seen from TYPO3 (e.g. listmonk or https://listmonk.internal).
GSB_NEWSLETTER_PORTyesListmonk HTTP port (default 9000).
GSB_NEWSLETTER_API_USERyesListmonk admin API username (used by upgrade wizards to bootstrap roles, lists, and site users).
GSB_NEWSLETTER_API_PASSWORDyesListmonk admin API password / token.
TYPO3__MAIL__defaultMailFromAddressyesDefault sender address. Written to site setting newsletter.api.senderEmail and used as Listmonk from_email.
TYPO3__MAIL__transport_smtp_serveryes (production)SMTP host for Listmonk outbound mail, optionally with port (host:port). Copied into Listmonk settings by the SMTP upgrade wizard.
TYPO3__MAIL__transport_smtp_usernamenoSMTP username; if both username and password are set, Listmonk uses login auth.
TYPO3__MAIL__transport_smtp_passwordnoSMTP password.

Example (Compose / DDEV-style):

- GSB_NEWSLETTER_HOST=listmonk
- GSB_NEWSLETTER_PORT=9000
- GSB_NEWSLETTER_API_USER=api_user
- GSB_NEWSLETTER_API_PASSWORD=<strong-secret>
- TYPO3__MAIL__defaultMailFromAddress=noreply@example.org
- TYPO3__MAIL__transport_smtp_server=smtp.example.org:587
- TYPO3__MAIL__transport_smtp_username=<smtp-user>
- TYPO3__MAIL__transport_smtp_password=<smtp-password>

After the per-site upgrade wizard has run, day-to-day API calls use the site-specific credentials stored in site settings (newsletter.api.username / newsletter.api.password), not the admin env vars.

Installing Listmonk

Listmonk needs PostgreSQL and an SMTP relay. Recommended: Docker Compose with the official image.

Minimal outline (see listmonk installation for the full compose file):

curl -LO https://github.com/knadh/listmonk/raw/master/docker-compose.yml
# Adjust DB passwords, ports, and volumes for your environment
LISTMONK_ADMIN_USER=admin LISTMONK_ADMIN_PASSWORD=<strong-secret> docker compose up -d

Key points for GSB:

  1. Expose Listmonk on port 9000 (or set GSB_NEWSLETTER_PORT accordingly).
  2. Ensure TYPO3 can resolve GSB_NEWSLETTER_HOST (same Docker network / cluster DNS).
  3. Persist PostgreSQL and the Listmonk uploads volume.
  4. Create the admin user on first start (LISTMONK_ADMIN_USER / LISTMONK_ADMIN_PASSWORD, or via the web UI at http://<host>:9000).
  5. Use those admin credentials as GSB_NEWSLETTER_API_USER / GSB_NEWSLETTER_API_PASSWORD in TYPO3.
  6. Provide a real SMTP relay (not the TYPO3 app server as public sender). Configure SPF/DKIM/DMARC for the sender domain.

A local DDEV reference stack lives in the project’s .ddev/docker-compose.listmonk.yaml (Listmonk + Postgres, profile listmonk). Production deployments should use hardened secrets and your own SMTP provider—not the DDEV defaults.

Configuring Listmonk for GSB

Prerequisites: Listmonk is running and environment variables are set.

  1. Apply the Listmonk SiteSet to each site that should use Listmonk:

    • Site set name: itzbund-gsb/newsletter-listmonk
    • Depends on itzbund-gsb/newsletter
    • In the GSB default site package this is typically already included.
  2. Run the TYPO3 upgrade wizards (Install Tool → Upgrade Wizard, or CLI). They are ordered by identifier prefix and should be executed in this order:

    IdentifierTitleWhat it does
    gsbnewsletter_a_initialListmonkNewsletterSettingsWizardListmonk newsletter setupDestructive bootstrap: deletes all Listmonk lists, subscribers, and templates other than IDs 1/3, then sets campaign template 1 and transactional template 3 (HTML via Tx.Data.html_body), and creates user role GSB. Do not run against a populated production Listmonk instance.
    gsbnewsletter_b_listmonkApiUserPerSiteWizardListmonk API User setup per sitePer site: creates list, list role, API user (newsletter_gsb_<rootPageId>), writes site settings.
    gsbnewsletter_c_initialListmonkSmtpSettingsWizardListmonk SMTP setupWrites SMTP from TYPO3__MAIL__transport_smtp_* into Listmonk; disables update checks.
    gsbnewsletter_d_listmonkUserRolePermissionsWizardListmonk user role permissions (GSB)Ensures role GSB has the full permission set including media:manage (required after A/B). Permissions: subscribers:get, subscribers:manage, subscribers:sql_query, tx:send, campaigns:manage, campaigns:send, media:manage.
    gsbnewsletter_e_ensureNewsletterSchedulerTaskWizardEnsure newsletter scheduler taskCreates one recurring Newsletter delivery (NLSchedulerTask) scheduler task with a 60-second interval if none exists. Does not create a duplicate.

    Run all four Listmonk wizards. Stopping after A/B leaves the GSB role without media:manage. Run wizard E so automatic sending has a scheduler task.

    Example CLI:

    vendor/bin/typo3 upgrade:run gsbnewsletter_a_initialListmonkNewsletterSettingsWizard
    vendor/bin/typo3 upgrade:run gsbnewsletter_b_listmonkApiUserPerSiteWizard
    vendor/bin/typo3 upgrade:run gsbnewsletter_c_initialListmonkSmtpSettingsWizard
    vendor/bin/typo3 upgrade:run gsbnewsletter_d_listmonkUserRolePermissionsWizard
    vendor/bin/typo3 upgrade:run gsbnewsletter_e_ensureNewsletterSchedulerTaskWizard
    
  3. Site settings written by the wizards (under config/sites/<site>/settings.yaml):

    SettingPurpose
    newsletter.api.urlFrom GSB_NEWSLETTER_HOST
    newsletter.api.portFrom GSB_NEWSLETTER_PORT
    newsletter.api.defaultListNameListmonk list ID for this site
    newsletter.api.username / newsletter.api.passwordPer-site API user (password encrypted)
    newsletter.api.senderEmailFrom TYPO3__MAIL__defaultMailFromAddress
    newsletter.listmonk.transactionalTemplateIdSet to 3 by the wizards (site-set definition default is 0 until then)
  4. Verify in the Listmonk UI (or via API): lists exist, SMTP is enabled, templates 1 and 3 match the expected bodies, and a test subscription / test email from TYPO3 succeeds.

Manual Listmonk UI setup is possible as a fallback, but the upgrade wizards are the supported path for GSB and keep sites, roles, and templates consistent.

MJML-based newsletter templates

HTML email templates for newsletters are authored in MJML and compiled into Fluid/HTML templates that are used by TYPO3.

Folder structure

MJML source files live in:

  • Mjml/Partials/...
  • Mjml/Templates/...

The compiled Fluid/HTML templates live in:

  • Resources/Private/Partials/...
  • Resources/Private/Templates/...

The directory structure under Mjml mirrors the structure under Resources/Private. File names are identical, only the extension differs:

  • Mjml/Partials/Content/Textpic.mjml → Resources/Private/Partials/Content/Textpic.html
  • Mjml/Templates/Newsletter/Default.mjml → Resources/Private/Templates/Newsletter/Default.html

Some content partials are Fluid-only (<mj-raw> without MJML layout); the build copies them through without compiling MJML.

How the build works

The MJML build is implemented in:

  • Mjml/package.json
  • Mjml/mjml-build.mjs

The script:

  • walks all .mjml files under Mjml
  • maps files from Partials/... and Templates/... to the corresponding path under Resources/Private
  • for content partials (Mjml/Partials/Content/*.mjml) it:
    • wraps MJML fragments (e.g. a single <mj-section>) in a minimal <mjml><mj-body>…</mj-body></mjml> wrapper for compilation
    • compiles MJML to HTML using the mjml CLI library
    • extracts exactly the generated <div class="…">…</div> block that corresponds to the MJML section
      • if the section has a css-class attribute, that class name is used (e.g. css-class="textpic-element")
      • otherwise a class name is derived from the file name (e.g. Textpic.mjml → textpic-element)
    • writes only this inner block to the target partial, preserving Fluid tags inside <mj-raw> blocks
  • for template files (Mjml/Templates/...) it writes the full compiled HTML document to the target template file
  • for .mjml files outside Partials/... and Templates/... it logs a warning and skips them (no hard failure)

Existing Fluid code inside the MJML files (e.g. {contentElement.header}, <f:sanitize.html>…</f:sanitize.html>, loops over images) is kept as-is by using <mj-raw> in the MJML source.

Running the MJML build (local and CI)

From within the extension:

cd _packages/gsb_newsletter/Mjml
npm install    # once
npm run build

It is safe to run repeatedly: the generated .html files under Resources/Private are fully overwritten based on the MJML sources and should be treated as build artefacts (single source of truth is the .mjml files).

Usage

The gsb_newsletter extension enables newsletter subscription and sending on TYPO3 pages. It talks to a Listmonk instance over HTTP/JSON; connection details come from site settings (see Configuring Listmonk for GSB).

What the extension does

  • Newsletter subscription and unsubscription via dedicated content elements (double opt-in for subscribe).
  • Email validation, honeypot spam protection, and a privacy checkbox on the subscription form.
  • Listmonk integration for subscribers, campaigns, and transactional (test / opt-in) mails.
  • List management backend module for Listmonk lists per site.
  • Automatic sending via TYPO3 scheduler task based on newsletter page configuration.
  • Test email field in the backend for newsletter pages.

Newsletter lists

Lists live in Listmonk, not as TYPO3 database records. TYPO3 only stores Listmonk list IDs on content elements and newsletter pages (newsletter_list).

API credentials and the default list ID come from site settings (newsletter.api.*), usually written by the upgrade wizards.

Managing lists

  1. In the TYPO3 backend, open Site Management → Newsletter lists (site_gsbnewsletter_list_management).
  2. Choose a site (root page).
  3. Create, edit, or delete Listmonk lists for that site via the module (calls the Listmonk API).

The site’s default list is newsletter.api.defaultListName (Listmonk list ID).

Selecting lists in content elements and pages

Subscription / unsubscription content elements and newsletter pages expose a newsletter_list field:

  • TCA: Configuration/TCA/Overrides/tt_content.php, pages.php
  • Options are loaded via NewsletterList::getNewsletterLists() → SelectableNewsletterListsEvent
  • SelectableListmonkListsEventListener fills the dropdown from active Listmonk lists for the current site

Cardinality:

  • Content elements: multi-select (selectMultipleSideBySide) — one or more Listmonk list IDs.
  • Newsletter pages: single select (selectSingle) — exactly one list for sending.

Frontend usage (subscription/unsubscription)

  1. Ensure Listmonk lists exist Create or verify lists in Site Management → Newsletter lists (or rely on the default list from the upgrade wizard).

  2. Subscription content element

    • Go to the Page module.
    • Add a content element of type Newsletter subscription (gsbnewsletter_newslettersubscription).
    • Configure:
      • Header and bodytext
      • Optional image (with alt/title)
      • Newsletter list: one or more Listmonk lists
  3. Unsubscription content element

    • Add a content element of type Newsletter unsubscription (gsbnewsletter_newsletterunsubscription).
    • Configure header, bodytext, optional image, and the list(s) to unsubscribe from.
  4. Privacy, validation, and spam protection

    • The subscription form always shows a privacy checkbox.
    • Email addresses are validated before Listmonk is called.
    • A honeypot field blocks simple bots.
    • Subscription uses double opt-in: the user receives a confirmation mail (Listmonk transactional template) and must confirm before being added to the list(s).

Newsletter pages and sending

Newsletter content is created as pages with doktype 5766 (Newsletter page) in the TYPO3 page tree.

For these pages:

  • A special backend layout and RTE preset are applied automatically via:
    • NewsletterPageBackendLayoutHook
    • RTE preset newsletter (Configuration/RTE/Newsletter.yaml)
  • The UI is optimized for e‑mail content (simplified allowed markup, etc.).

A newsletter page should:

  • Belong to a site with newsletter / Listmonk site settings.
  • Contain newsletter content elements (e.g. text+image) as needed for the rendered mail.
  • Target a Listmonk list via pages.newsletter_list, or fall back to newsletter.api.defaultListName.

Test e-mail field

The extension registers FormEngine node NewsletterTestEmail (ITZBund\GsbNewsletter\Backend\FormEngine\NewsletterTestEmail):

  • Shown in the page properties of newsletter pages (tx_gsbnewsletter_test_email).
  • Editors can send a test e‑mail of the current newsletter to a specified address.
  • Uses the same rendering and Listmonk strategy as a real send, but only a single test recipient (transactional API).

Ready to send

The scheduler picks up pages that match all of the following (NewsletterSendService::getNewslettersReadyToSend()):

ConditionField / value
Newsletter pagedoktype = 5766
Not deleted / not hiddendeleted = 0, hidden = 0
Marked readytx_gsbnewsletter_ready_to_send = 1
Schedule reachedtx_gsbnewsletter_schedule_date < now

Editors set the schedule date and toggle ready to send in the page properties. After a successful send, the service clears the ready flag and records status / sent date.

Backend usage: scheduler task for sending

The scheduler task is registered in ext_localconf.php as NLSchedulerTask:

  • Class: ITZBund\GsbNewsletter\Task\NLSchedulerTask
  • Title: Newsletter delivery

The upgrade wizard gsbnewsletter_e_ensureNewsletterSchedulerTaskWizard creates this task automatically when no NLSchedulerTask exists yet. The created task is recurring with a 60-second interval.

To configure it manually (fallback):

  1. In the TYPO3 backend, go to System → Scheduler.
  2. Create a new task.
  3. Choose task class Newsletter delivery (ITZBund\GsbNewsletter\Task\NLSchedulerTask).
  4. Configure the execution schedule (e.g. every 60 seconds).

There is no Scheduler UI field for dry run. The task class has an internal $dryRun property (default false) used only if set programmatically.

Task execution flow (NLSchedulerTask::execute()):

  1. Resolve the NewsletterSendService (lazy).
  2. Call getNewslettersReadyToSend() (see criteria above).
  3. For each newsletter page:
    • If dry run: log that the newsletter would be sent (page ID and title) and continue.
    • Otherwise call sendNewsletter((int)$newsletter['uid']) on the service.
    • Log success or failure with details.
  4. After processing all pages, log a summary with totals and dryRun status.

If any newsletter fails to send, the task logs the error and returns false so the scheduler marks the run as failed.

Extension overview and extensibility

Architecture

The extension uses a strategy pattern so the newsletter backend can be swapped without changing controllers and services. The shipped implementation is Listmonk (Strategy\NewsletterApi\Listmonk). With a single implementor of NewsletterApiInterface, Symfony DI autowires it into NewsletterApi; there is no explicit alias in Configuration/Services.yaml.

Key components:

ComponentPurpose
NewsletterApiInterfaceStrategy contract: subscribe, unsubscribe, sendNewsletter, sendTestEmail, sendOptInEmail (all take NewsletterConfiguration / NewsletterContent).
NewsletterApiFacade used by controllers and services. Validates input, translates messages and delegates to the injected strategy.
Strategy\NewsletterApi\ListmonkListmonk implementation (HTTP/JSON: subscribers, campaigns, transactional mails).
NewsletterConfigurationDTO with Listmonk API URL, credentials, sender, list ID, and strategy options (from site settings).
CampaignListRepositoryLoads/creates Listmonk lists used by the list management module and TCA selects.
NewsletterSendServiceCollects newsletter pages, renders content and calls NewsletterApi::sendNewsletter().

Subscribe/unsubscribe flow:

  1. A frontend user submits a subscription or unsubscription form.
  2. The controller validates the request (including honeypot) and resolves selected Listmonk list IDs from newsletter_list.
  3. For subscribe: double opt-in mail is sent; after confirmation the subscriber is added in Listmonk.
  4. Site settings supply API URL, credentials, and sender via NewsletterConfiguration.
  5. NewsletterApi validates the email and delegates to the Listmonk strategy.

Send flow:

  1. NewsletterSendService collects newsletter pages that are ready to send (doktype 5766, ready flag, schedule date).
  2. For each page, the service:
    • Resolves the Listmonk list ID from pages.newsletter_list or newsletter.api.defaultListName.
    • Builds NewsletterConfiguration from site settings.
    • Renders the newsletter content (HTML and plain text).
    • Calls NewsletterApi::sendNewsletter() to create/send the Listmonk campaign.
  3. The Listmonk strategy performs the API calls and throws ListmonkApiException on error.

Custom backends

If you need a different backend, implement all five methods of NewsletterApiInterface and wire the strategy explicitly (required once more than one implementor exists):

services:
  ITZBund\GsbNewsletter\Strategy\NewsletterApiInterface:
    alias: Vendor\Site\Extension\Strategy\NewsletterApi\CustomBackend

  ITZBund\GsbNewsletter\Strategy\NewsletterApi:
    public: true
    arguments:
      $newsletterStrategy: '@ITZBund\GsbNewsletter\Strategy\NewsletterApiInterface'

After clearing caches, subscription, unsubscription and send operations use your custom backend; forms, list management UI, and the scheduler task stay unchanged.

Contribute

As with TYPO3, we encourage you to join the project by submitting changes. Development of the GSB 11 happens mainly in the GSB 11 TYPO3 extension repositories.

To get started, have a look at our detailed contribution walkthrough.