cethyworks/twig-swift-message

使用 twig 提供 Swift_Message 构建器。

v2.0 2017-08-14 23:57 UTC

This package is not auto-updated.

Last update: 2024-09-21 15:18:15 UTC


README

使用 twig 构建 Swift_Message,并可选择使用 CssToInlineStyles 将 css 内联。

CircleCI

安装

1. Composer 需要

$ composer require cethyworks/twig-swift-message

如何使用

1. 使用 3 个区块 subjectbody_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. 添加您的收件人。并发送它!