Skip to content

Instantly share code, notes, and snippets.

@havvg
Last active December 18, 2015 19:09
Show Gist options
  • Select an option

  • Save havvg/5830959 to your computer and use it in GitHub Desktop.

Select an option

Save havvg/5830959 to your computer and use it in GitHub Desktop.
Symfony2: using Swift_FailoverTransport with Swift_SpoolTransport
services:
# A spooling implementation.
acme.spool.queued:
class: Acme\Mailer\QueuedSpool
# The transport using the spool above.
acme.transport.spool:
class: Swift_SpoolTransport
arguments:
- '@acme.spool.queued'
# The transport to be used.
acme.failover_transport:
class: "%swiftmailer.transport.failover.class%"
calls:
# This call sets the transports:
# The first one will be the configured transport (like smtp, ..) utilizing SwiftmailerBundle configuration.
# The second transport in use is the spool transport defined above.
- [ 'setTransports', [ [ '@swiftmailer.transport', '@acme.transport.spool' ] ] ]
# This alias is required to have the "swiftmailer:spool:send" command working.
# The current stable release is not capable of utilizing it, see https://github.com/symfony/SwiftmailerBundle/pull/40
swiftmailer.transport.real:
alias: acme.failover_transport
# Overwriting the configured mailer service to use the failover instead of the configured transport.
swiftmailer.mailer:
class: '%swiftmailer.class%'
public: false
arguments:
- '@acme.failover_transport'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment