Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,113 of 9,113 pages
About the help in other languages
All help pages

Specification: the cjw_newsletter extension

This page is the reference for the cjw_newsletter extension (4.1.17). It lists the admin views and their parameters, the console commands, the cronjob parts, the background runs, the audit events, the tables and the…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/specifications/6.0/cjw_newsletter.md

On this page

Specification: the cjw_newsletter extension

This page is the reference for the cjw_newsletter extension (4.1.17). It lists the admin views and their parameters, the console commands, the cronjob parts, the background runs, the audit events, the tables and the settings you can change. Read it if you install, schedule, script or debug the newsletter. The tour for editors and the rehearsal without mail is on the feature page.

In short

  • Admin entry point: /newsletter/index (the Newsletter tab): a dashboard with the lists and subscribers, the editions, the last sends, the transport and the outbox, the last runs and the problems found.
  • Three cronjob parts do the work: cjw_newsletter_mailqueue_create and cjw_newsletter_mailqueue_process (the part cjw_newsletter runs both) and cjw_newsletter_mailbox for bounces.
  • Five console commands run the same code by hand: ext:cjw_newsletter:queue, mailbox, import, repair and status.
  • Ten tables cjwnl_*, created from sql/<database>/schema.sql or from share/db_schema.dba.
  • The left menu comes from design/standard/templates/parts/newsletter/menu.tpl (navigation part eznewsletternavigationpart) in every admin design.

Example: send a newsletter from the shell and look at the result

Switch the transport to files (see the feature page), publish an edition, press Send Newsletter in the admin, then:

./console ext:cjw_newsletter:queue --dry-run     # what a run would do, nothing changed
./console ext:cjw_newsletter:queue               # create the queue, send the mails
./console ext:cjw_newsletter:status              # lists, users, sends, outbox, last runs, problems

queue prints Queue: 1 sends, 4 items created. and Sent 4 mails, 0 failed, 1 sends finished.; each mail is a file in the outbox. A second run at the same time prints Another queue run is active. and exits with 1.

Module newsletter

Views of the admin and of the public forms. A view keeps its URL since 4.0; the parameters below are the (name)/value pairs of the URL.

ViewPolicy functionParametersWhat it does
indexindex(job)The dashboard; starts "Send now", "Count only", "Process the mail accounts" and "Remove them" in the background
jobindexJobIDThe state of a background run as JSON (status, result, log)
user_listuser_list(q), (status), (list), (sort), (order), (offset), (limit)Users: status is confirmed, pending, removed, bounced or blacklisted; sort is email, name, status, created or id; limit is 10, 25, 50 or 100
user_view, user_edit, user_create, user_removeuser_view, user_edit, user_create, user_removeNewsletterUserIdOne user; removal also removes the subscriptions
subscription_list, subscription_viewsubscription_list, subscription_viewNodeId, SubscriptionIdSubscriptions of a list
blacklist_item_listblacklist_item(q), (sort), (order), (offset), (limit)The blacklist; sort is created, email or id
blacklist_item_add, blacklist_item_removeblacklist_itemnoneAdd (validated); remove asks first (ConfirmRemoveButton)
mailbox_list, mailbox_editmailbox_list, mailbox_editMailboxIdMail accounts; the form validates every field, never shows the password and removal asks first
mailbox_item_list, mailbox_item_viewmailbox_item_list, mailbox_item_view(job), (limit), (offset), MailboxItemIdCollected mails; "Collect all mails" and "Parse mails" are POST buttons that start a background run
import_list, import_viewimport_list, import_view(limit), (offset), ImportIdCSV imports, newest first
subscription_list_csvimport, subscription_list_csvexportsubscription_list_csvimport, subscription_list_csvexportNodeId, ImportIdCSV import (the policy subscription_list_csvimport_import allows "Import all") and export
send, send_abort, preview, preview_archive, archivesend, preview, archivesee the viewSending, test mail, archive
subscribe, subscribe_infomail, configure, unsubscribesubscribe, configure, unsubscribehashesThe public forms; the back link of a form is a path of this site only

Console commands

All of them start with ./console ext:cjw_newsletter:<name> or php extension/cjw_newsletter/bin/php/<name>.php, take --help, and have the alias nl-<name>. Exit code 0 is success, 1 is a failure or another run holding the lock.

CommandOptionsWhat it does
queue--dry-run, --create-only, --send-only, --job=IDConfirms users that waited for their eZ user, wakes the sends whose time has come, creates the queue and sends the mails
mailbox--dry-run, --collect-only, --parse-only, --job=IDReads the active mail accounts and parses the bounces
import--import-id=N (required), --delimiter=comma|semicolon|pipe|tab, --formats=0-1, --first-row-label, --dry-run, --job=IDImports an uploaded CSV file of the import folder
repair--dry-run, --job=IDRemoves subscriptions of removed users and unsent mails that can never be sent
statusnonePrints what the dashboard shows

--job is set by the admin when it starts a command in the background: the command writes its state to var/cjw_newsletter/jobs/<id>.json and its output to <id>.log, and the page shows both while it polls newsletter/job/<id>.

Cronjob parts

PartScriptWhat it does
cjw_newsletterboth scripts belowCreates the queue, then sends
cjw_newsletter_mailqueue_createcronjobs/cjw_newsletter_mailqueue_create.phpAs queue --create-only
cjw_newsletter_mailqueue_processcronjobs/cjw_newsletter_mailqueue_process.phpAs queue --send-only
cjw_newsletter_mailboxcronjobs/cjw_newsletter_mailbox.phpAs mailbox; not in the part cjw_newsletter

The script files are one line each; the code is in classes/runnable/cronjobs/, and the cron parts, the commands and the admin all call CjwNewsletterRunner. A run takes a file lock (queue_create, queue_process, mailbox, repair, import), so two runs of one kind never overlap, whoever starts them. The time, the user (cron, console, job) and the totals of the last run of each kind are kept in ezsite_data (cjw_newsletter_last_*).

Audit events

One event per run, written when the audit is on: system.cjw_newsletter.queue_create, queue_process, mailbox, import and repair. object is cjw_newsletter:<run>, after holds who started it and the totals; result is failed with the reason run when the run had errors. A dry run writes nothing. The branch is registered in settings/audit.ini.append.php.

Settings you can change

FileBlockKeyDefaultMeaning
cjw_newsletter.iniNewsletterCsvImportSettingsImportInBackgroundenabledenabled starts the import of "Import all" as a command in the background; disabled (or a server without proc_open) imports inside the request
cjw_newsletter.iniNewsletterMailSettingsTransportMethodCronjobfilesmtp, sendmail or file for the mails of the queue
cjw_newsletter.iniNewsletterMailSettingsFileTransportMailDirvar/log/mailWhere file writes .eml files; the dashboard counts them
cjw_newsletter.iniNewsletterUserSettingsCustomFieldMappingArray[], [CustomFieldMapping_<field>] Namenot setPublic names of the custom data fields in the user view
cronjob.iniCronjobPart-cjw_newsletter_mailboxScripts[]cjw_newsletter_mailbox.phpThe part that reads the mail accounts

Problems the dashboard reports

ProblemMeaningWhat to do
Tables missingcjwnl_* tables are not createdCreate them from share/db_schema.dba
Newsletter folder missingRootFolderNodeId names no nodeCreate the tree (CjwNewsletterClassInstaller::installTree()) or set the node
Mails are written to filesTransportMethodCronjob is fileIntended for a rehearsal; switch to smtp or sendmail to send
Default sender addressEmailSender is still @example.*Set it in the ini or on each list
OrphansSubscriptions of removed users, unsent mails of removed usersPress Remove them or run repair
Stuck sendsA send waits for more than a dayCheck that cron runs cjw_newsletter
Bounced users, unparsed mails, no active mail accountSee the textThe bounces page and the mail accounts

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x