I have used SwiftMailer a number of times for basic email sending, however I am trying to get the grips on sending more streamlined emails - so as to allow quicker creation of emails using templates.
I know I can manually create a template using the Decorator Plugin but this still feels very manual?
When I am building my PHP code I generally use TWIG templates, is there a way this can be integrated into SwiftMailer so I can send a predefined template using variables defined at the time of sending?
Ok so I managed to find a way to do this, for anyone who may be looking at trying this, the following code is a good example :
$message_content = $app->render('email.template.twig',
array('name'=>'JustSteveKing', 'age'=>26));
$transport = Swift_SmtpTransport::newInstance("$host", $port)
->setUsername("$email")
->setPassword("$password");
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance("$title")
->setFrom(array("$sender_email" => "$sender_name"))
->setTo(array("$reciever_email"))
->setBody($message_content,'text/html');
$result = $mailer->send($message);