moritz-sauer-13/silverstripe-templated-emails
最新稳定版本:2.0.0
Composer 安装命令:
composer require moritz-sauer-13/silverstripe-templated-emails
包简介
Adds an easy way to create email templates in SilverStripe
README 文档
README
A SilverStripe module that provides a unified, theme‑ready email template and automatically renders form data as a table—no manual HTML needed.
Installation
-
Install the package (in your project directory):
composer require moritz-sauer-13/silverstripe-templated-emails
-
Update database/manifest:
- run /dev/build?flush=all
Requirements: SilverStripe CMS 5.x
Quick start
use SilverStripe\Control\Email\Email; use TemplatedMails\Model\TemplatedEmail; $email = TemplatedEmail::create() ->setTo('to@example.com') ->setFrom(Email::config()->admin_email) ->setSubject('Contact request') ->setGreeting('Hello,') ->setTitle('New contact request') ->setFormData($data, $form); $email->send();
- If a
$formis provided, the order and labels are derived from the form fields. - Additional free text/HTML can still be set via
$email->setBody()and rendered in the template with$EmailContent.RAW.
Configuration (YAML)
Keys and defaults:
- skip_empty: true — Skip empty fields (default)
- excludes: ["SecurityID", "url", "g-recaptcha-response"] — Exclude exact key names
- exclude_prefixes: ["action_"] — Exclude all keys starting with any of these prefixes
- array_separator: ", " — Separator for array values
- label_from_placeholder: true — Use placeholder as label when Title is empty
- strip_required_asterisk: true — Remove trailing asterisk on required field labels
Example app/_config/email.yml:
TemplatedMails\Model\TemplatedEmail: skip_empty: true excludes: - SecurityID - url - g-recaptcha-response exclude_prefixes: - 'action_' array_separator: ', ' label_from_placeholder: true strip_required_asterisk: true
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-10-01
