PHP code example of rollerworks / mail-bundle

1. Go to this page and download the library: Download rollerworks/mail-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rollerworks / mail-bundle example snippets




// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Rollerworks\Bundle\MailBundle\RollerworksMailBundle(),
    // ...
);



// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Rollerworks\Bundle\MailBundle\RollerworksMailBundle(),
    // ...
);



// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Rollerworks' => __DIR__.'/../vendor/bundles',
    // ...
));

 array('data'     => 'raw-file-content',
       'filename' => 'some-file.txt',
       'type'     => 'optional mime-type')



$replacements = array(
    "[email protected]" => array(new \Swift_Attachment::fromPath('/path/to/image.jpg', 'image/jpeg')),
    "[email protected]" => array(array('data' => 'Please read me...', 'filename' => 'agreement.txt', 'type' => 'text/plain'))
);

$decorator = new \Rollerworks\Bundle\MailBundle\Decorator\TemplateDecorator($replacements);
$mailer->registerPlugin($decorator);
bash
$ php composer.phar update
bash
$ php bin/vendors install
 php


// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Rollerworks\Bundle\MailBundle\RollerworksMailBundle(),
    // ...
);
 php


// Replacements must be an array or implementation of \Swift_Plugins_Decorator_Replacements
// Each key is an e-mail address and the value an array that is directly passed to render() of the templating engine.

$replacements = array(
    "[email protected]" => array("a" => "b", "c" => "d"),
    "[email protected]" => array("a" => "x", "c" => "y")
);

// Template filename follows the Symfony template resolving convention ([Bundle]:[Dir]:[filename].[type].[ext]).
$templates = array(
    'html' => 'AcmeHelloBundle:Email:Order.html.twig',
    'text' => 'AcmeHelloBundle:Email:Order.txt.twig'
);

$templating = $container->get('templating');

$decorator = new \Rollerworks\Bundle\MailBundle\Decorator\TemplateDecorator($templating, $replacements, $templates);
$mailer->registerPlugin($decorator);