I did just this type of thing a while back. I read an article on this site, sorry I don't recall the title.
My problem was also with using PHP var's in the email's. I don't know how other people do it, but I created by basic form and where I needed to use PHP vars I created tags:
[USERNAME]
[MESSAGE1]
and like that. Then I use eregi() to repalce the marker tags with the value of the vars! It works slick for me anyway.
Here is a bit of code I use...maybe it will give you some ideas.
$fp = fopen("$GLOBALS[DOCUMENT_ROOT]/newuser/welcome.inc.html", "r");
if ($fp) {
while (!feof($fp))
{
$send_body .= fgets($fp, 100);
}
fclose($fp);
} else {
//build some error here if file open fails...
Print ("File open failed very badly!");
exit;
}
$send_body = eregi_replace("[s_user]", $s_user, $send_body);
$send_body = eregi_replace("[firstname]", $firstName, $send_body);
$send_body = eregi_replace("[lastname]", $lastName, $send_body);
$send_body = eregi_replace("[password]", $password, $send_body);
$send_body = eregi_replace("[answer]", $secret_a, $send_body);
$send_body = eregi_replace("[question]", $secret_q, $send_body);
$send_body = eregi_replace("[city]", $city, $send_body);
$send_body = eregi_replace("[state]", $state, $send_body);
$send_body = eregi_replace("[zip]", $zip, $send_body);
$sentMail = mail($email, $subject, $send_body, $headers);
}