Download the PHP package psmb/newsletter without Composer

On this page you can find all versions of the php package psmb/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 newsletter

Psmb.Newsletter

With this package you can generate newsletters based on content of your Neos CMS website (e.g. digest of latest articles).

The cool part is that you render those newsletters using Fusion, which allows you to reuse any of your existing website Fusion objects and be completely flexible.

Installation

composer require "psmb/newsletter:@dev"

Configuration

Put something like this into your Settings.yaml:

You also have to configure a baseUri in your Settings.yaml

Define as many subscription types under Psmb.Newsletter.subscriptions as you need.

setting key description
identifier Identifier of the subscription
renderer Fusion object that would be used for rendering emails sent to this subscription. Defaults to Psmb.Newsletter:MailRenderer. Must inherit from it.
sendFromUiNodeType Show this subscription for the nodes of given nodetype when sending from UI.
interval Time interval identifier that would be used for selecting subscriptions. Can be used for cron jobs. Those marked as manual would appear as options when sending from the UI. Optional.
senderName, senderAddress Override options from globalSettings.
dimensions Array of dimensions in form of "dimensionName: ['dimensionValues']". Falls back to default dimension values.

Also you may need to configure SwiftMailer, see its docs how to do that.

Rendering newsletters

As said before, we render letters purely in Fusion, so it's completely up to you to define the rendering objects. Entry point to rendering is newsletter = Psmb.Newsletter:SubscriptionCase, so you may hook straight into Psmb.Newsletter:SubscriptionCase to intercept the rendering process. But the intended usage is to provide a different renderer per each subscription preset via the renderer setting key (see above).

Then define a Fusion object like this for each renderer:

You'd have the following context variables available:

Context variable name Description
site,documentNode,node All point to site root node.
subscriber Subscriber object. Has name and email keys.
subscription Settings array for current subscription. interval key may be the most interesting one for generating lists of latest articles for given period.
globalSettings Global settings array.
activationLink Only available when generating email confirmation letters.

A more practical example:

Provided Fusion objects

Object name Description
Psmb.Newsletter:MailRenderer Abstract mail renderer. Returns a RawArray of body, subject and other mail options passed to swiftmailer. See above for details.
Psmb.Newsletter:EditSubscriptionLink Generated a link to edit action of the plugin
Psmb.Newsletter:UnsubscribeLink Generated a link to unsubscribe action of the plugin
Psmb.Newsletter:CssToInline Processor to automatically inline CSS styles
Psmb.Newsletter:SubscriptionCase Rendering entry point. Usually no need to touch this one
Psmb.Newsletter:SubscriptionPlugin Configured Neos.Neos:Plugin instance that insert Flow signup plugin.

To customize the confirmation mail, override Psmb.Newsletter:ConfirmationMailRenderer.

Rendering signup plugin

Insert Psmb.Newsletter:SubscriptionPlugin nodetype or render it manually.

Subscription has the following flow:

  1. Fill in the sign up form. Asks for name, and email, and allows to choose between available subscription plans.
  2. Confirm email.
  3. Edit subscription options or unsubscribe from email links.

You absolutely have to override the default templates, the default ones are there just for demo purpose. Create a Views.yaml file in Configuration:

Sending things out

Once you are ready setting up rendering of your subscriptions, it's time to send the out! There's a CLI command for it.

./flow newsletter:send --subscription="daily" would send out newsletter to all users subscribed to subscription with identifier "daily".

./flow newsletter:send --interval="P1H" would find all subscriptions with interval equal to "P1H" and send out letters to them. This is useful for setting up cron tasks based on time interval.

Manual sending from the UI

image

If your nodetype inherits from Psmb.Newsletter:NewsletterMixin you would see a new inspector tab from which you would be able to send manual newsletters, based on the current document node.

For this to work, one or more of your subscription presets must have interval: manual. Those presets would appear in the inspector view selectbox. Click send, and the newsletter would be send out to all subscribers of the chosen subscription group. Current document node would be available in the Fusion renderer as documentNode and node.

Improving reliabillity with job queue

This package uses flowpack/jobqueue package to generate and deliver messages. Refer to its docs how to improve its reliabillity via proper job queue implementations.

Importing subscribers from CSV

Create a CSV file with your subscribers data and put it somewhere on your server.

The file should have the following format:

Then run (file path is relative to installation root):

./flow newsletter:importCsv --filename="test.csv"

Here's a quick example how to create CSV exports from mysql:

External Datasources

The default datasource for fetching subscribers has an identifier Repository. It fetches all subscribers subscribed via the default subscription plugin.

You may fetch subscribers from an external JSON source via the Json datasource. Here's an example:

Alternatively you may provide your custom datasources. See implementation of JsonDataSource.php to see how to do that.

It is also possible to provide some additional arguments for the datasource that would be filled from other properties of a node. Here is an example NodeTypes.yaml for this:

Then the dataSourceAdditionalArguments would be passed to a datasource. You may check out how Json datasource handles it.

Acknowledgements

This is my first Flow package, and it wouldn't have been possible without a support of the community by answering dozens of n00b questions on Slack, by Christian Müller in particular.


All versions of newsletter with dependencies

PHP Build Version
Package Version
Requires neos/neos Version ^3.0 || ^4.0
psmb/registry Version *
neos/swiftmailer Version *
flowpack/jobqueue-common Version *
tijsverkoyen/css-to-inline-styles Version ^2.2
soundasleep/html2text Version ~0.3
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 psmb/newsletter contains the following files

Loading the files please wait ....