libre-informatique/email-bundle

Symfony 的邮件包

安装次数: 2,591

依赖关系: 2

建议者: 0

安全: 0

星标: 0

关注者: 7

分支: 2

类型:symfony-bundle

0.6.4 2017-11-03 15:08 UTC

This package is not auto-updated.

Last update: 2024-09-09 06:29:13 UTC


README

Travis Coveralls License

Latest Stable Version Latest Unstable Version Total Downloads

关于

Libre Informatique 的 EmailBundle 利用 Swiftmailer 和 Libre Informatique 的 CoreBundle 提供无缝的邮件和时事通讯功能。功能包括数据库队列,可配置的队列刷新命令,邮件打开和链接点击跟踪以及统计显示,内联附件,模板化,复制...

安装

$ composer require libre-informatique/email-bundle

// app/AppKernel.php
// ...
public function registerBundles()
{
    $bundles = array(
        // ...
            
        // the libre-informatique bundles
        new Librinfo\EmailBundle\LibrinfoEmailBundle(),
            
        // your personal bundles
        // ...
    );
}

配置

依赖关系

    // app/AppKernel.php
    // ...
    public function registerBundles()
    {
        $bundles = array(
            // ...
            
            // Sonata
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
            new Sonata\AdminBundle\SonataAdminBundle(),
            new Sonata\IntlBundle\SonataIntlBundle(),

            // Blast
            new Blast\OuterExtensionBundle\BlastOuterExtensionBundle(),
            new Blast\CoreBundle\BlastCoreBundle(),
            new lbr\BlastTestBundle\BlastTestBundle(),
            new Blast\BaseEntitiesBundle\BlastBaseEntitiesBundle(),
            new Blast\UtilsBundle\BlastUtilsBundle(),

            // Attachments
            new Librinfo\MediaBundle\LibrinfoMediaBundle(), 
          
            // Wisiwig editor
            new Stfalcon\Bundle\TinymceBundle\StfalconTinymceBundle(),

            // your personal bundles
            // ...
        );
    }
    // ...
# app/config/routing.yml
admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /
  
_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /

blast_core:
    resource: "@BlastCoreBundle/Resources/config/routing.yml" 
    prefix:   /admin

email:
    resource: "@LibrinfoEmailBundle/Resources/config/routing.yml"
    prefix: /admin
# app/config/config.yml
sonata_block:
    default_contexts: [cms]
    blocks:
        # Enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts:   [admin]
        # Your other blocks

但请参考源文档以获取最新信息:https://sonata-project.org/bundles/admin/2-3/doc/reference/installation.html

请注意,前缀值是 / 而不是 Sonata 项目建议的 /admin。这意味着这种访问是通用的,而不是特定的“后端”界面。这是专注于专业工作流程的软件包的一个特性。

不要忘记发布资产,因为捆绑包的一些功能(如文件上传)高度依赖于 JavaScript。

将自定义表单字段模板添加到您的 config.yml 中

# app/config/config.yml
twig:
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    form_themes:
        - 'SonataCoreBundle:Form:datepicker.html.twig'
        - 'SonataCoreBundle:Form:colorpicker.html.twig'
        - 'BlastCoreBundle:Admin/Form:fields.html.twig'
        - 'BlastUtilsBundle:Form:fields.html.twig'
        - 'BlastBaseEntitiesBundle:Form:fields.html.twig'
        - 'LibrinfoMediaBundle:Form:fields.html.twig'

队列

为了使用数据库队列功能,您需要配置两个邮件发送者,如下所示(一个用于直接发送,另一个用于队列发送)

# app/config/config.yml

swiftmailer:
    default_mailer: direct_mailer
    mailers:
        direct_mailer:
            transport: "%mailer_transport%"
            host:      "%mailer_host%"
            username:  "%mailer_user%"
            password:  "%mailer_password%"
        spool_mailer:
            transport: "%mailer_transport%"
            host:      "%mailer_host%"
            username:  "%mailer_user%"
            password:  "%mailer_password%"
            spool: { type: db }

要刷新队列,请执行以下命令: $ app/console librinfo:spool:send

不要犹豫,使用 --help 执行命令,因为它比 swiftmailer:spool:send 有更多选项

跟踪

如果您想使用跟踪功能,您需要在 security.yml 中添加一个访问控制规则,允许匿名用户访问以 '/tracking' 为前缀的路由,如下所示

# app/config/security.yml
access_control:
        # ...
        - { path: ^/tracking, role: IS_AUTHENTICATED_ANONYMOUSLY } # allow access to tracking controller for anonymous users

就是这样!