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(blah@blah.com, 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? Quote 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="blah@blah.com"; $subject="emotions"; $body="hello i feel very ".$emotion." today. ".$question; mail($email, $emotions, $body); Quote 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 Quote 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 Quote 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? Quote 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 = "your.email@domain.com"; $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. Quote 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 Quote 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 Quote 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 Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.