Jump to content

[SOLVED] How to display variables in php mail body?


Recommended Posts

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?

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.