disjfa/mail-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

disjfa/mail-bundle

Composer 安装命令:

composer require disjfa/mail-bundle

包简介

Mail bundle for symfony, can also be use in glynn-admin-symfony

README 文档

README

Check on packagist MIT License

Watch on GitHub Star on GitHub Tweet

Why is this bundle here

In every project i need to build a way to send emails. Now symfony has released the Mime Component and the Mailer Component. Lets see what we can do to make live easier for us people who send emails.

Instalation

composer require disjfa/mail-bundle

Setup the interface

Setup the routes in config/routes/disjfa_mail.yaml. Here you can edit emails setup in your application.

disjfa_mail:
    resource: '@DisjfaMailBundle/Controller/'
    type: annotation
    prefix: '/admin'

Make you own template

Create a class that extends the MailInterface. Implement the name, subject and content as you want. You can inject the Translator to add simple translations or the twig Environment to render out templates.

<?php
namespace Disjfa\MailBundle\Mail;

interface MailInterface
{
    public function getName();
    public function getSubject();
    public function getContent();
}

In your templates there should be no twig variables. Escape those, like this: {{ '{{' }} email {{ '}}' }}. All the variables used are parsed and collected. The original variables are the only ones that should be used.

If you made a class it will be autoload in the MailCollection collection. And so editable if you have set up some routes for the interface.

Sending emails

Next up is sending emails. In your code just make a message or function that sets up the email.

use Disjfa\MailBundle\Mail\MailFactory;
use Disjfa\MailBundle\Mail\MailService;

function myFunction(MailFactory $mailFactory, MailService $mailService)
{
    $mail = $mailFactory->findByName('name');
    $mailService->send($mail, [
         'param1' => 'value',
         'param2' => 'value',
    ], 'info@example.com');
}

And done! Mail sent. Now it is time to setup emails and make more in your application.

Extend the templates

You can manage the templates as is. But you probably want to integrate the files in your own system. Just create a file in your application in templates/bundles/DisjfaMailBundle/layout.html.twig and add a body block.

<!doctype html>
<html>
<head>
...
</head>
<body>
{% block body %}

{% endblock %}
</body>
</html>

And you are good to go. Or you can just extend your own template. Just make sure you use a block named body. You can also just extend the rest of the files as you wish. Just name them like we set up the files.

One thing missing

One thing missing is sending the emails. We do not have to set up the mailing bit of the application. You can do that yourself. Check the transports on how to set up your own mailer as you wish.

And that is about it.

Now you can make your own emails. Set them up. Create a method to send emails. And when you have set up your favorite mailer you can send them!

Help

This bundle is a nice way to extend your workflow. But it can be improved. If you have any ideas or solutions to do so don't be shy and tell us! We can only make stuff better in the end.

Enjoy!

Use the bundle. Check what the bundle does. Fork. Make your own. This is here just to make live easier for us all. Make something beautiful.

disjfa/mail-bundle 适用场景与选型建议

disjfa/mail-bundle 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 11 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mail」 「symfony」 「Symfony Bundle」 「email template」 「inky」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 disjfa/mail-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 disjfa/mail-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 disjfa/mail-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: CSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-14