anvd
anvd

Reputation: 4047

Echo variable from phpmailer in template

How can i pass a variable from phpmailer to contents.php (template file) ? I need to pass the $email variable.

$mail -> msgHTML(file_get_contents('contents.php'), dirname(__FILE__));

contents.php

<div>
    This email was sent by x. <a href="www.x.com/process_contact.php?email="<?php echo $email ?> Unsubscribe </a>from this email.
</div> 

Upvotes: 0

Views: 1197

Answers (1)

scrowler
scrowler

Reputation: 24435

Replace a known tag with your email:

$email = '[email protected]';
$mail -> msgHTML(str_replace('[emailhere]', $email, file_get_contents('contents.php')), dirname(__FILE__));

contents.php

<div>
    This email was sent by x. <a href="www.x.com/process_contact.php?email=[emailhere]"> Unsubscribe </a>from this email.
</div> 

Manual: http://php.net/manual/en/function.str-replace.php

Upvotes: 1

Related Questions