The "ATS DIGITAL" Symfony Email bundle.

Installs: 4

Dependents: 1

Suggesters: 0

Security: 0


2.0.0 2019-02-05 17:03 UTC

This package is not auto-updated.

Last update: 2021-09-19 20:06:06 UTC



  • Email handler Bundle

Features & Capabilities

  • SimpleMailerService the provides an overlay above the SwiftMailerBundle
  • ReST end-points to send an email or resend an existing one
  • Email document class for document persistence


1- Update your composer.json to add ATS private packagist:

    "repositories": [
            "type": "composer",
            "url": ""

2- Install the bundle in your application

$ php composer require ats/email-bundle

3- Register the bundle in the AppKernel

class AppKernel extends Kernel
    public function registerBundles()
        $bundles = [
            // ...
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
            new ATS\CoreBundle\ATSCoreBundle(),
            new ATS\EmailBundle\ATSEmailBundle(),
            // ...
    // ...


# Example configuration
    api_prefix: 'my-new-api-prefix'
    provider: swiftmailer
        transport: gmail
        password: pa$$

Note: When the api_prefix is not given, a default (api) will be used instead


  • The bundle provides a SimpleMailerService and an Email document class as a super layer above the SwiftMailerBundle. Sending an email is then as simple as calling the send() method method from the SimpleMailerService class
// php file

    $doSave = false;
    $email = new Email();
    $email->setTemplate("my-template.html.twig") // template file must be valid and accessible
          ->setMessageParameters($parameters) // $parameters is an associative array
          ->setSubject("Email subject")
          ->setFrom("") // Sender's address
          ->setFromName("John Doe")
          ->setCc(['', ''])
    $mailerService = $this->getContainer()->get('ats_email.service.simple_mailer');
    $mailerService->send($email, $doSave); // When the $doSave parameter is set to true, the email will be persisted in the DataBase
  • The bundle also provides 2 end-points:
      POST /%api_prefix%/email/send/{doSave}

    When set to true, the doSave parameter will save the email into the database after sending the email. When set to false, the controller action will only send an email to the specified recepient. Note that doSave defaults to false

      POST /%api_prefix%/email/resend/{id}

    Where id is the MongId of the email object that needs to be resent

What's new?