PHPackages                             vsavritsky/mail-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. [Mail &amp; Notifications](/categories/mail)
4. /
5. vsavritsky/mail-bundle

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

vsavritsky/mail-bundle
======================

Mail manager

0.6.3(3y ago)0327MITPHPPHP &gt;=8.1

Since May 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/vsavritsky/MailBundle)[ Packagist](https://packagist.org/packages/vsavritsky/mail-bundle)[ RSS](/packages/vsavritsky-mail-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (5)Versions (16)Used By (0)

MailBundle
==========

[](#mailbundle)

[![Build Status](https://camo.githubusercontent.com/4224079337ea23483fe74d1e34584ab45057bc98a42e36f39916610d9804f4bb/68747470733a2f2f7472617669732d63692e6f72672f657874656c6c69656e742f4d61696c42756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/extellient/MailBundle)[![codecov](https://camo.githubusercontent.com/1717343e33cc3bdacdb737d1cb57bd98bfa2b18ab9533844ac3fddb329e0a5c9/68747470733a2f2f636f6465636f762e696f2f67682f657874656c6c69656e742f4d61696c42756e646c652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/extellient/MailBundle)[![Codacy Badge](https://camo.githubusercontent.com/030e054c47ec4b6158b71797c4c85934b5af96e31acdce1c6eb394c72261d718/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6362383861623466373164653430616638393934653564393861633631663434)](https://www.codacy.com/app/xtladmin/MailBundle?utm_source=github.com&utm_medium=referral&utm_content=extellient/MailBundle&utm_campaign=Badge_Grade)

This is MailBundle is Symfony 3.4+ Bundle, for building your own html mail powered with [Twig](https://github.com/twigphp/Twig) and customizing it. You can easily save your mail to your database before sending it besides your database provider, finally send your mail with your own provider, the default is [SwiftMailer](https://github.com/swiftmailer/swiftmailer)

Features
--------

[](#features)

- Save your mail inside your database before sending it
- Build your own mail template with twig
- Save your mail template inside your database
- Easily integrate with your database provider
- Easily integrate with your mailing provider
- Send all your mail at once with the symfony command

Installation
------------

[](#installation)

With [composer](http://packagist.org), require:

`composer require extellient/mail-bundle`

Then enable it in your kernel:

```
// app/AppKernel.php Symfony 3.4+
public function registerBundles()
{
    $bundles = array(
        //...
        new Extellient\MailBundle\MailBundle(),
        //...
    );
```

```
// config/bundles.php Symfony 4+

return [
    //...
    Extellient\MailBundle\MailBundle::class => ['all' => true],
    //...
];
```

Now you have to update your database to get the two tables (`Mail`, `MailTemplate`)

```
#Symfony 3.4+
php bin/console doctrine:migrations:update
```

Configuration
-------------

[](#configuration)

You need to configure the default mail.

```
# app/config/services.yml Symfony 3.4+
# config/package/extellient_mail.yaml Symfony 4+
extellient_mail:
    mail_address_from: ''
    mail_alias_from: ''
    mail_reply_to: ''
```

The default configuration use the Doctrine bridge for the database, Twig for the templating and SwiftMailer to send mail. You don't need to create this file if you want to use the default configuration

```
# app/config/extelient_mail.yml Symfony 3.4+
# config/package/extelient_mail.yml Symfony 4+
extellient_mail:
    mail_service_provider: 'Extellient\MailBundle\Provider\Mail\DoctrineMailProvider' #The database provider to get mails
    mail_template_service_provider: 'Extellient\MailBundle\Provider\Template\DoctrineMailTemplateProvider' # The database provider to get templates
    mail_sender_service_provider: 'Extellient\MailBundle\Sender\SwiftMailSender' #The Mail provider that will be use to send mails
```

Usage
-----

[](#usage)

### Insert your first template inside your database

[](#insert-your-first-template-inside-your-database)

```
INSERT INTO `mail_template` (`id`, `created_at`, `updated_at`, `mail_subject`, `mail_body`, `code`) VALUES (1, '2018-03-14 09:44:28', '2018-04-20 15:11:38', 'Reset your password', 'Hello,{{link_password_reset}}', 'reset_password'),
```

```
// src/controller/HomeController.php
