nswdpc/silverstripe-structured-email

Structured email for Silverstripe

Installs: 64

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 1

Type:silverstripe-vendormodule

v0.2.1 2024-04-16 23:29 UTC

This package is auto-updated.

Last update: 2024-09-15 03:34:31 UTC


README

The goal of this module is to produce simple and easy-to-digest emails (more). The templates used are based on the Postmark Transactional Email Templates.

The StructuredEmail class extends the Email class. You can use it standalone or you may wish to inject StructuredEmail as the Email class for your project using Injector.

For specific core emails, it will attempt to detect the purpose of the email based on the template name:

  • SilverStripe/Control/Email/ForgotPasswordEmail - the forgot password email
  • SilverStripe/Control/Email/ChangePasswordEmail - the changed password email

TODO:

  • SilverStripe/MFA/Email/* - MFA emails
  • SilverStripe/ContentReview/* - Content review emails
  • SubmittedFormEmail - user defined form generic email
  • SubmittedFormEmailPlain - user defined form generic email (plain text)

Existing templates

If the class encounters a complete HTML document in the email, it will use HTML contained within the <body> tag of that document as the email content.

Schema.org

Reference

Resources

Quick example

For finer grain control, use StructuredEmail directly.

See further documentation

<?php
// Your custom HTML body
$html = ArrayData::create([
    'Name' => $name,
    'CallToAction' => $link
])->renderWith('My/Template');

$data = [
    'Body' => $html// Your email HTML
];

$email = StructuredEmail::create();
$email->setTo(["to@example.com", "To name"]);
$email->setFrom(["from@example.com" => "From name"]);
$email->setData($data);
// will automatically pick up StructuredEmail.ss as the template
$email->send();

Emails are decorated using a standard, basic colour palette from the NSW Design System. You can provide your own decorator.

Installation

The only supported way of installing this module is via composer

composer require nswdpc/silverstripe-structured-email

License

BSD-3-Clause

Maintainers

The source of the HTML email templates is the Postmark templates project

Bugtracker

We welcome bug reports, pull requests and feature requests on the Github Issue tracker for this project.

Please review the code of conduct prior to opening a new issue.

Security

If you have found a security issue with this module, please email digital[@]dpc.nsw.gov.au in the first instance, detailing your findings.

Development and contribution

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.

Please review the code of conduct prior to completing a pull request.