whiteoctober/swiftmailerdbbundle

此包已弃用且不再维护。未建议替代包。

SwiftMailer 的数据库转储

1.1.1 2018-08-24 13:14 UTC

This package is auto-updated.

Last update: 2020-11-13 20:11:53 UTC


README

本项目正在寻找维护者 - 详情请见此处.

SwiftMailerDBBundle

该项目最初位于 https://github.com/whiteoctober/WhiteOctoberSwiftMailerDBBundle

Latest Stable Version Total Downloads Monthly Downloads License

SwiftMailer

此扩展包使得使用数据库将消息转储到 SwiftMailer 和 Symfony2 变得容易。

目前,它只与 Doctrine EntityManager 以及使用它管理的实体一起工作。

安装和配置

1. 通过 Composer 安装

$ composer require "whiteoctober/swiftmailerdbbundle:^1.0"

2. 将扩展包添加到应用的内核

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new WhiteOctober\SwiftMailerDBBundle\WhiteOctoberSwiftMailerDBBundle(),
        // ...
    );
}

3. 在 config.yml 中配置 white_october_swift_mailer_db

white_october_swift_mailer_db:
    entity_class: AppBundle\Entity\Email

下面将详细介绍如何构建此实体。

4. 告诉 SwiftMailer 使用数据库转储

swiftmailer:
    spool:
        type: db

扩展包的安装和配置就到这里。

邮件实体

您需要创建一个可以持久化和从扩展包中的 EmailInterface 接口扩展的实体。目前,扩展包期望您的实体中有一个名为 'status' 的属性,因为这个字段将被查询。

一旦您的实体设置好,就在 config.yml 配置中使用上述详细的完全命名空间路径。

可选:在数据库中保留已发送的消息

默认情况下,成功发送的消息将从数据库中删除。您可以配置扩展包在 config.yml 中保留这些消息。

white_october_swift_mailer_db:
    keep_sent_messages: true

可选:为电子邮件使用单独的实体管理器

当使用配置的数据库转储发送消息时,会在默认实体管理器上调用 $em->flush。这可能会导致副作用,因此,为了只刷新 Email 实体,请将其放入单独的扩展包,并为该扩展包配置单独的实体管理器。例如

white_october_swift_mailer_db:
    entity_class: MailBundle\Entity\Email

doctrine:
    orm:
        entity_managers:
            default:
                connection: default
                auto_mapping: true
            mail:
                connection: default
                mappings:
                    MailBundle: ~

贡献

我们欢迎对这个项目做出贡献,包括拉取请求和问题(以及对现有问题的讨论)。

如果您想贡献代码但不确定从何开始,可以从问题列表入手。如果您是首次贡献代码,GitHub关于分叉项目的指南可能对您有所帮助。

所有贡献者(无论是贡献代码、参与问题讨论,还是以其他任何方式参与)都必须遵守我们的行为准则