I'm trying to do a nicely formatted email from a plugin I'm making. The standard way I've been doing simple emails is all entirely in the code, somewhat like this:
$notificationEmail = new EmailModel(); $notificationEmail -> toEmail = $userEmail; $notificationEmail -> subject = "Subject here"; $notificationEmail -> body = "Thanks $userName, you’re now registered on our website."; $notificationEmail -> htmlBody = " ... MASSIVE COMPLICATED STUFF THATS FAR BETTER SUITED TO TWIG ... " craft()->email->sendEmail($notificationEmail);
I've now got an email that is far better suited to being generated via a Twig template because I'm going to have to loop through relational fields and all sorts. I have no idea how and I don't seem to know what to Google to get what I'm after... Anyone got pointers to this sort of thing?