PHPackages                             tweedegolf/swiftmailer-logger-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. tweedegolf/swiftmailer-logger-bundle

AbandonedLibrary[Logging &amp; Monitoring](/categories/logging)

tweedegolf/swiftmailer-logger-bundle
====================================

Log emails sent with Swift Mailer

109.0k↓23.3%7[2 issues](https://github.com/tweedegolf/swiftmailer-logger-bundle/issues)PHP

Since Aug 12Pushed 4y ago16 watchersCompare

[ Source](https://github.com/tweedegolf/swiftmailer-logger-bundle)[ Packagist](https://packagist.org/packages/tweedegolf/swiftmailer-logger-bundle)[ RSS](/packages/tweedegolf-swiftmailer-logger-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

SwiftmailerLoggerBundle
=======================

[](#swiftmailerloggerbundle)

The tweedegolf SwiftmailerLoggerBundle provides an easy way to log messages sent with Swift Mailer. Currently the bundle only provides an 'entity logger', which uses its `LoggedMessage` Doctrine entity to store the details of a message that was sent. In the near future, a file logger will be added. Please note that the bundle is a work in progress and pay attention to the issue that was reported on 10-9-2014 about using lifecycle events.

Installation and configuration
------------------------------

[](#installation-and-configuration)

Using [Composer](https://getcomposer.org/), please run the following command to add the bundle to your composer.json and to install it immediately:

```
composer require tweedegolf/swiftmailer-logger-bundle:dev-master

```

### Basic configuration

[](#basic-configuration)

Add the following configuration to your configuration file `app/config/config.yml`:

```
tweede_golf_swiftmailer_logger:
    loggers:
        entity_logger:
            enabled: true
        symfony_logger:
            enabled: true

```

This will enable the only logger that is currently available: the entity logger.

### Add the bundle to your AppKernel

[](#add-the-bundle-to-your-appkernel)

Add the bundle in `app/AppKernel.php`, as shown below:

```
public function registerBundles()
{
    return array(
        // ...
        new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
        new TweedeGolf\SwiftmailerLoggerBundle\TweedeGolfSwiftmailerLoggerBundle(),
        // ...
    );
}
```

### Update your database schema

[](#update-your-database-schema)

Finally, update your database schema such that `LoggedMessage` entities can be stored by Doctrine.

Usage
-----

[](#usage)

With the above all set up, logging is automatic. The bundle provides a listener that listens to the `Swift_Events_SendEvent sendPerformed` event on which it passes on the data to be logged to any loggers configured.

### What is being logged?

[](#what-is-being-logged)

Every time an email is sent in your app with Swiftmailer, an LoggedMessage record is written to the database. This record contains the following info

- the from, to, replyTo, cc and bcc address fields, all stored as array type
- the return path (string)
- the subject of the message
- the body of the message
- the date and time that the message was sent
- the sending result
- any failed recipients

Of these, the sending result and failed recipients require some explanation. The sending result always contains one of the following strings "pending", "success", "tentative", "failed" or "unknown" representing the results (except for "spooled") that a Swift\_Events\_SendEvent can have. In the failed recipients field recipients are logged for which a Swift\_RfcComplianceException or Swift\_TransportException was thrown during sending. Note that a "success" result and no failed recipients *does not mean* that all recipients actually received the email that was logged: we only no that there were no problems during sending.

### Retrieving logged messages

[](#retrieving-logged-messages)

The bundle provides an empty `LoggedMessage` repository that can be used to retrieve messages logged by the entity logger. Retrieve it for example in one of your controllers by using:

```
$repo = $this->getDoctrine()->getRepository("TweedeGolfSwiftmailerLoggerBundle:LoggedMessage");

```

### Use multiple or custom instances of Swift mailer

[](#use-multiple-or-custom-instances-of-swift-mailer)

If you are using multiple Swift instances on your application or if you have overwritten the name of your Swift instance, modify your `app/config.yml` as shown below:

```
tweede_golf_swiftmailer_logger:
   swift_instances:
        - default
        - secondary_smtp

    loggers:
        entity_logger:
            enabled: true

```

Using multiple Swift instances, your Swiftmailer configuration will look something like this:

```
swiftmailer:
    default_mailer: default
    mailers:
        default:
            transport:  %swift_transport%
            username: %swift_username%
            password: %swift_password%

        secondary_smtp:
            transport:  %swift_transport2%
            username: %swift_username2%
            password: %swift_password2%

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8df75c1b70003dca1beac9b4cd2f57b8f144cc20a4af6d0d227c64d1c48f1baf?d=identicon)[tweedegolf](/maintainers/tweedegolf)

---

Top Contributors

[![hugovandepol](https://avatars.githubusercontent.com/u/8415466?v=4)](https://github.com/hugovandepol "hugovandepol (20 commits)")[![Ddall](https://avatars.githubusercontent.com/u/1160683?v=4)](https://github.com/Ddall "Ddall (8 commits)")[![marlonbaeten](https://avatars.githubusercontent.com/u/885089?v=4)](https://github.com/marlonbaeten "marlonbaeten (7 commits)")[![bramtweedegolf](https://avatars.githubusercontent.com/u/6331700?v=4)](https://github.com/bramtweedegolf "bramtweedegolf (1 commits)")

### Embed Badge

![Health badge](/badges/tweedegolf-swiftmailer-logger-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tweedegolf-swiftmailer-logger-bundle/health.svg)](https://phpackages.com/packages/tweedegolf-swiftmailer-logger-bundle)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[ekino/newrelic-bundle

Integrate New Relic into Symfony2

28111.2M8](/packages/ekino-newrelic-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
