PHP code example of phps-cans / mail.swift.renderer-twig

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

    

phps-cans / mail.swift.renderer-twig 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);