eschmar/mailer-bundle

在 Symfony 4 中方便地发送 html/plaintext 电子邮件。

安装: 244

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

语言:HTML

类型:symfony-bundle

v1.0.1 2018-10-17 20:19 UTC

This package is auto-updated.

Last update: 2024-09-11 19:56:39 UTC


README

在 Symfony4 中方便地发送 html/plaintext 电子邮件。此捆绑包附带 Mailgun 的 Action Email 版本,可直接发送电子邮件。

test.html.twig

安装

Composer (Packagist)

composer require eschmar/mailer-bundle ^1.0.0

使用

eschmar_mailer 服务期望模板包含 3 个块 subjectbody_htmlbody_plain,并已包含一个布局文件 @EschmarMailer/Mail/layout.html.twig,可直接使用。我建议不要使用嵌入的 base64 图像,这只是为了演示目的。当然,这个布局是完全可选的,您可以构建自己的模板。使用 Twig 标签 {% cssinline %}{% endcssinline %},CSS 样式将被内联(一些电子邮件客户端会去除 <head><style> 标签)。

use Eschmar\MailerBundle\Service\Mailer;
// ...

if (!$mailer->send("@EschmarMailer/Mail/test.html.twig", [], $from, $to[, $bcc])) {
    // Oops!
    return;
}

// success

许可证

MIT 许可证。