PHP code example of thecodingmachine / swift-twig-mail-template

1. Go to this page and download the library: Download thecodingmachine/swift-twig-mail-template 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/ */

    

thecodingmachine / swift-twig-mail-template example snippets


// We assume that $twigEnvironment is a valid TwigEnvironment instance
$twigSwiftMailTemplate =  new SwiftTwigMailTemplate($twigEnvironment, 'path/to/template.twig');

// The renderMail method generates a Swift mail object.
$swiftMail = $twigSwiftMailTemplate->renderMail(['paramKey' => paramValue]);

// We fill the swift mail with additional information
$swiftMail->setFrom('[email protected]');
$swiftMail->setTo('[email protected]');

// We assume that $mailer is a valid Swift_Mailer instance
$mailer->send($swiftMail);