2017 © Pedro Peláez
 

symfony-bundle symfony-mailer-bundle

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

image

tomazahlin/symfony-mailer-bundle

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  • Tuesday, May 22, 2018
  • by tomazahlin
  • Repository
  • 1 Watchers
  • 5 Stars
  • 3,302 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 19 Versions
  • 10 % Grown

The README.md

Symfony2 Mailer Bundle

Build Status, (*1)

SensioLabsInsight, (*2)

This is the explanation of how the bundle is structured and also an installation / example tutorial for the bundle., (*3)

Mailer bundle allows you to write very clean code when sending emails. By default it uses Swiftmailer, but if you want, you can override the complete mailer implementation and use some other mailer library. Emails can be forwarded (send) to Swiftmailer directly in the code where you require it, and also if you implement a queueable mailer, sending of the mails can be postponed until Symfony's kernel.terminate event, which is handled after the output is already sent to the user, so the user does not notice the delay of the mailing., (*4)

The code is coupled to the Symfony2 framework, as it is presented in the bundle. It might be decoupled later if needed or requested., (*5)

Installation

Use composer to require the bundle inside composer.json by running the command:

``` bash php composer.phar require tomazahlin/symfony-mailer-bundle, (*6)


### Enable the bundle in your AppKernel.php ``` php public function registerBundles() { $bundles = array( // ... new Ahlin\Bundle\MailerBundle\AhlinMailerBundle(), ); }

Run tests

``` bash bin/phpunit bin/phpspec run, (*7)


## Usage [View a controller with examples here](https://github.com/tomazahlin/symfony-mailer-bundle/blob/master/src/Ahlin/Bundle/MailerBundle/Controller/ExampleController.php) The bundle provides you with the mailing service which gives you access to other services as well, because it uses composition. It exposes one service, so you only have to inject one dependency, preferably the MailingInterface, to keep things decoupled. ``` php namespace Company\App; use Ahlin\Mailer\MailingInterface; class MyService { private $mailing; public function __construct(MailingInterface $mailing) { $this->mailing = $mailing; } public function doSomething() { // How to access factory to create mail instances $factory = $this->mailing->getFactory(); // How to access mailer to send or queue the mail $mailer = $this->mailing->getMailer(); } }

To define your service, you should inject the ahlin_mailer.mailing service:, (*8)

``` xml , (*9)


## Templates To override anything in the bundle, you can of course use bundle inheritance, but for simplicity you can also override some classes by overriding some of the default parameters of the bundle. And to override templates you can define your custom templates in app/Resources. The bundle is packaged with a default responsive html template: - Resources/views/Mail/default.html.twig You can easily replace the template, by defining your own in app/Resources folder or you can use bundle inheritance to do the same. To define your own templates, the bundle uses Open for extension / closed for modification solid principle. To define your own templates, you need to create a class and tag it with "ahlin_mailer.mapping". Let's say you wanted to create a mapping for your UserBundle. Create a class which implements TemplateMappingInterface. ``` php namespace Company\Bundle\UserBundle\Mapping; use Ahlin\Mailer\Mapping\TemplateMappingInterface; class UserMapping implements TemplateMappingInterface { public function getMappings() { return array( 'registration' => array('view' => 'CompanyUserBundle:Mail:registration.html.twig', 'contentType' => 'text/html'), 'activation' => array('view' => 'CompanyUserBundle:Mail:activation.html.twig', 'contentType' => 'text/html'), 'forgot_password' => array('view' => 'CompanyUserBundle:Mail:forgot_password.html.twig', 'contentType' => 'text/html'), ); } }

As you can see, it is only a mapping between aliases and their paths, so when you need to specify which template you want to use, your code will be much shorter and cleaner. And the service definition for the container would look like this:, (*10)

``` xml , (*11)


You can define (override) the parameters which are always passed to the email templates, by overriding the parameter: ``` xml <parameter type="collection" key="ahlin_mailer.default.parameters"> <parameter key="myHomepageUrl" type="string">https://localhost</parameter> </parameter>

In the twig template, you can access it with {{ myHomepageUrl }}., (*12)

For any questions or issues regarding this bundle, please do not hesitate to ask. Feel free to create your own forked version or submit any pull requests., (*13)

Version 2.2 allows you to add Filters, which modify the email's body. Some filters (if they maybe convert images from url to inline images) also can modify the Swift_Message model. All you have to do is to implement FilterInterface and tag the filter with "ahlin_mailer.filter"., (*14)

Version 2.2 allows you to use the Mailer class to send Swfit_Message instances., (*15)

The Versions

22/05 2018

dev-master

9999999-dev

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

22/05 2018

2.2.2

2.2.2.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

22/05 2018

2.3

2.3.0.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

22/05 2018

dev-develop

dev-develop

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

07/02 2018

2.2.1

2.2.1.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

09/06 2016

2.2

2.2.0.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

25/04 2016

2.1.2

2.1.2.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

18/04 2016

2.1.1

2.1.1.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

07/10 2015

2.1.0

2.1.0.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

06/10 2015

2.0.5

2.0.5.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

06/10 2015

2.0.4

2.0.4.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

06/10 2015

2.0.3

2.0.3.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

05/10 2015

2.0.2

2.0.2.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

28/06 2015

2.0.1

2.0.1.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

27/05 2015

1.1

1.1.0.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

27/05 2015

2.0

2.0.0.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

03/05 2015

1.0.2

1.0.2.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

02/05 2015

1.0.1

1.0.1.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer

13/04 2015

1.0

1.0.0.0

Mailer bundle provides a mailer (mail broker) implementation (Swiftmailer wrapper) for Symfony2 framework. It enables you to send mails in a very elegant way while providing extension points for needed modifications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tomaz Ahlin

mail symfony2 bundle mailer