PHP code example of eresults / email-template-bundle

1. Go to this page and download the library: Download eresults/email-template-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/ */

    

eresults / email-template-bundle example snippets


// app/AppKernel.php
public function registerBundles() 
{
    $bundles = [
        // ...
        new eResults\EmailTemplateBundle\eResultsEmailTemplateBundle(),
    ];
}


// ...
class UserController extends Controller
{
    public function registerAction(LoaderInterface $loader, \Swift_Mailer $mailer) {
        // ...
        if ($form->isValid()) {
            //.. handle your form
            $formData = array(
                'email' => '[email protected]',
                'first_name' => 'John',
                'last_name' => 'Doe',
            );

            $template = $loader->load('email/user_registered.html.twig', $formData);
            $message = \Swift_Message::newInstance()
                ->setSubject($template->getSubject())
                ->setFrom($template->getFrom())
                ->setBody($template->getBody(), 'text/html')
                ->setTo($formData['email'])
            ;

            $mailer->send($message);
        }
    }
}