2017 © Pedro PelĂĄez
 

symfony-bundle quick-mailer-bundle

image

felds/quick-mailer-bundle

  • Tuesday, July 10, 2018
  • by felds
  • Repository
  • 1 Watchers
  • 0 Stars
  • 70 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 23 Versions
  • 71 % Grown

The README.md

QuickMailerBundle

This bundle provides an easily configurable façade for sending transactional emails without having to build the message from scratch every time., (*1)

It has a limited scope by design, it's not infinitely configurable and it's not made to work outside a typical Symfony installation., (*2)

Installation

Step 0: Before we begin

Under the hood, QuickMailer uses Twig as its template engine, SwiftMailer to actually send the messages and Monolog to keep tabs on what is happening., (*3)

Make sure that those three bundles are installed and properly configured., (*4)

Step 1: Download the bundle

Open a terminal, cd into your project directory and execute the following command to download the latest stable version of this bundle:, (*5)

composer require felds/quick-mailer-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*6)

If you are using Symfony Flex and have contrib recipes enabled, it's all done., (*7)

Configuration

to be done, (*8)

Usage

Step 1: Create a template

Using this bundle, the whole message is composed from a single twig template., (*9)

The typical message looks something like this:, (*10)

{# templates/email/cookie.html.twig #}

{% block subject %}
Hey, {{ name|title }}! You've got a cookie!
{% endblock %}

{% block html %}


{{ name|title }}, take this delicious {{ flavor }} cookie! , (*11)

{% endblock %} {% block text %} {{ name|title }}, take this delicious {{ flavor }} cookie! {% endblock %}

Of course, you can use includes, extends and everything else available on Twig (even your own extensions!). Just keep in mind that each main block (subject, html and text) are rendered separately, and they are not visible to one another. Ex: a set declared outside the html block will not work inside it., (*12)

Step 2: Add it to the configuration

# config/packages/felds_quickmailer.yaml
felds_quickmailer:
    # ...
    templates:
        cookie: email/cookie.html.twig

Step 3: Send the email

<?php

use Felds\QuickMailerBundle\Model\Mailable;
use Felds\QuickMailerBundle\QuickMailer;

class FooController
{
    public function barAction(QuickMailer $qm)
    {
        $recipient = new Mailable('Recipient', 'recipient@example.com');

        $qm->get('cookie')->sendTo($recipient, [
            'name'    => $recipient->getName(),
            'flavor'  => 'blueberry',
        ]);
    }
}

To do

Code

  • [ ] Add tests

Docs

  • [ ] Config reference
  • [ ] Examples of how to integrate it with other tools
  • [ ] Guides

The Versions

15/01 2018

2.0.0

2.0.0.0

  Sources   Download

MIT

The Requires

 

by Luiz “Felds” Liscia

16/06 2017

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

by Luiz “Felds” Liscia

16/06 2017

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

by Luiz “Felds” Liscia

16/06 2017

0.2.1

0.2.1.0

  Sources   Download

MIT

The Requires

 

by Luiz “Felds” Liscia

16/06 2017

0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

by Luiz “Felds” Liscia

14/06 2017

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

by Luiz “Felds” Liscia