How can I inject PHP variables into my XML email templates?
My templates are structured like this:
<Template id="1" name="Registration">
<![CDATA[
<p>Dear $FullName,</p>
<p>We would like to welcome you to oursite. Please find your activation link below, <br />
if you cannot click the link, please copy and paste the link into your browser.</p>
<ul>
<li><strong>Activation Link:</strong> <a href="http://example.com/activate/$actCode/$UserName">http://example.com/activate/$actCode/$UserName</a></li>
</ul>
<p> </p>
<p>Thank you,<br />
~Kevin - our site</p>
]]>
</Template>
and the code I am pulling it in with is:
public function PullEmailTemplate($which, $id){
$file = $which . '.config';
$xml = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . '/assets/templates/' . $file, NULL, LIBXML_NOCDATA);
$res = $xml->xpath("//Template[@id='" . $id . "']");
return (string)$res[0];
}
and using it like:
$msg = PullEmailTemplate('user', 1);
Now, the email sends out successfully, but I get $FullName
, $ActCode
, and $UserName
exactly as they are... in otherwords, the aren't outputting what they should be... for instance they should be (in order): Kevin
, 12345
, myuser@name.com
How can I do this?