cethyworks / twig-swift-message
使用 twig 提供 Swift_Message 构建器。
v2.0
2017-08-14 23:57 UTC
Requires
- php: >=5.6.17
- swiftmailer/swiftmailer: ^5.3|^6.0
- tijsverkoyen/css-to-inline-styles: ^2.2
- twig/twig: ^1.0||^2.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is not auto-updated.
Last update: 2024-09-21 15:18:15 UTC
README
使用 twig 构建 Swift_Message
,并可选择使用 CssToInlineStyles 将 css 内联。
安装
1. Composer 需要
$ composer require cethyworks/twig-swift-message
如何使用
1. 使用 3 个区块 subject
、body_html
和/或 body_txt
创建您的 twig 模板(所有 区块都是可选的)。
{% block subject %}subject{% endblock subject %}
{% block style %}.baz {color:red;}{% endblock style %}
{% block body_html %}
{{ foo }}<br>
<p class="baz">bar</p>
{% endblock body_html %}
{% block body_txt %}
{{ foo }}
bar
{% endblock body_txt %}
2. 调用 TwigSwiftMessageBuilder::buildMessage()
/** @var Swift_Message $swiftMessage */
$swiftMessage = $messageBuilder->buildMessage($templateName, $templateParameters);
3. 添加您的收件人。并发送它!