Thauwa Posted December 24, 2008 Share Posted December 24, 2008 Now I have some variables. I want them to be displayed in the body of mail. $emotion = "happy" $question = "Do you feel happy?" mail([email protected], emotions, hello i feel very $emotion today. $question) I want the variables to display as their values in the mail. The code shown above does not work. I just typed it to show what I want. Can anyone help me? Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/ Share on other sites More sharing options...
ILMV Posted December 24, 2008 Share Posted December 24, 2008 $email="[email protected]"; $subject="emotions"; $body="hello i feel very ".$emotion." today. ".$question; mail($email, $emotions, $body); Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723035 Share on other sites More sharing options...
Thauwa Posted December 24, 2008 Author Share Posted December 24, 2008 what is the var '$emotions' you used in the mail() function? tks by the way Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723037 Share on other sites More sharing options...
ILMV Posted December 24, 2008 Share Posted December 24, 2008 oh! That was meant to be $subject Its been a long morning Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723042 Share on other sites More sharing options...
Thauwa Posted December 24, 2008 Author Share Posted December 24, 2008 i tried it ILMV... my host is godaddy. it dosent work. isn't there another way? Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723043 Share on other sites More sharing options...
careym1989 Posted December 24, 2008 Share Posted December 24, 2008 Give this a try: <?php $to = "[email protected]"; $subject = "Hello!"; $emotion = "Happy"; $question = "Do you feel happy?"; $body = "Hello, I feel "; $body .= $emotion; $body .= " today. "; $body .= $question; $query = mail($to, $subject, $body); if($query) { echo "Emailed successfully."; } ?> If you upload this, as I did (as query.php), and "Emailed successfully." echoes back, it should've worked. Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723052 Share on other sites More sharing options...
Adam Posted December 24, 2008 Share Posted December 24, 2008 i tried it ILMV... my host is godaddy. it dosent work. isn't there another way? What exactly doesn't work with it, are you getting an error? It's possible your email providers see it as spam, check your spam folder! Who is your email provider? AOL are extremely hard to please! A Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723086 Share on other sites More sharing options...
Thauwa Posted December 24, 2008 Author Share Posted December 24, 2008 i get the email but the variable values dont show up Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723090 Share on other sites More sharing options...
Adam Posted December 24, 2008 Share Posted December 24, 2008 Post your code exactly as you have it.. A Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723092 Share on other sites More sharing options...
Thauwa Posted December 24, 2008 Author Share Posted December 24, 2008 careym..i think your code works. let me try it with my system.. mr adam. i tried with my original code, but instead of the var value, i get an emptiness. i also tried echo'ing and print'ing, with no result. Link to comment https://forums.phpfreaks.com/topic/138289-solved-how-to-display-variables-in-php-mail-body/#findComment-723124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.