you could have avoided the whole riggamora of that thing by just stating:
$to = "$email@example.com
here's why it didn't work.
$email = '$firstname.lastname@example.org
This single tick blocks transformation of variables to strings in output.
Using double quotes " " will transform variables to strings in output.
$to = $email;
An un-needed, unnecessary step. creating two variables with the exact same information is ... you get the idea.