Data in emails.


I am sending emails using the mail(). When using var’s in the subject it should print the data in the var’s. Such as Hello $EDFName $EDLName, should print “Hello Billy Bob,” not “Hello $EDFName $EDLName,” like it is. Both $EDFName and $EDLName contains the data, also If it didn’t it would just print “Hello ,”. So I am obviosly doing sothing to cause it to not be phrased as data. Thanks in advance for any assistence, Im sure it is somthing simple.

Here is my code:
$To = $EDEmail;
$HTo = “$EDFName $EDLName <$EDEmail>”;
$Subject = “$FSubject”;
$Message = “$DAEmailBody”;



The To is working fine All the var’s above are comming from a database query.

Email.php contains:
$Headers = “MIME-Version: 1.0rn”;
$Headers .= “Content-type: text/html; charset=iso-8859-1rn”;
$Headers .= “To: $HTorn”;
$Headers .= “From: $HFromrn”;

mail($To, $Subject, $Message, $Headers);

Thank You.


How about something like:

$HTo = $EDFName . ’ ’ . $EDLName. ‘<’ . $EDEmail . ‘>’;

Granted that isn’t for the subject header but… try using single quotes with the concatinator.


Didn’t work.

Since then, I have tried diffrent variations with no luck.


I narrowed it down to the fact that it is comming from the database. Not sure how to fix it though. If I Set $Message = “Hello $EDFName $EDLName” then use mail I get the correct responce. But If I retrive “Hello $EDFName $EDLName” from the database such as in the privious code it does not work:

$DAEmailBody = $row[‘EmailBody’];
later …
$Message = $DAEmailBody;
Tried with single and double quotes. If I put single quotes around $DAEmailBody I recieve a email with just $DAEmailBody as the body.


if they are echoed out what does it look like?


Ok this is what I just did to test them out. When I echo them out they show just like the are emailed. But after I edited the post I relized that I was wrong in assuming that it was a database problem. Since the subject is doing the same thing when it is being passed from a form on the prievious page. Here is what I did to test it out, I don’t understand why I got the results I did, but I am sure it is the key to the problem. I added the bottom two lines to the script:

$Subject = “$FSubject”;
$Message = “$DAEmailBody”;

$Subject = "Hello $EDFName $EDLName,";

echo "$FSubject,<br>$Subject,<br>$DAEmailBody,<br>$Message";


This is the output;
Hello $EDFName $EDLName,
Hello Bobby ,
Hello $EDFName $EDLName,
Hello $EDFName $EDLName


I can’t see where the problem is off hand maybe if we were to see the form as well as the PHP pertaining to the sending of the email. If you don’t want everyone to see it all you can just PM me.


Thanks for your help. I don’t mind too much if everyone sees my code, it is just that it is very long and messy. I went ahead and PM’d you a link to the pages.



FYI - I’m on the phphelp IRC now if you want to try to figure it out.