Database spooling for SwiftMailer

1.0.4 2014-12-15 09:06 UTC


Latest Stable Version Total Downloads Monthly Downloads License


This bundle faciliates using a database to spool messages to with SwiftMailer and Symfony2.

At present, it only works with the Doctrine EntityManager and entities managed with this.

Installation and configuration

1. Install via Composer

$ composer require "whiteoctober/swiftmailerdbbundle:^1.0"

2. Add the bundle to your application's kernel

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

3. Configure the white_october_swift_mailer_db in config.yml

    entity_class: AppBundle\Entity\Email

Read below about how to construct this entity.

4. Tell SwiftMailer to use the database spooler

        type: db

That's it for bundle installation and configuration.

Mail entity

You will need to create an entity that can be persisted and that extends from the EmailInterface interface in the bundle. At the moment, the bundle expects a property to be available on your entity called 'status', since this field is queried.

Once you have your entity all set up, use the full namespaced path in your config.yml configuration as detailed above.

Optional: keeping sent messages in the database

By default, messages which were succesfully sent will be deleted from the database. It is possible to configure the bundle to keep those messages in your config.yml:

    keep_sent_messages: true