Jump to content

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


Thauwa

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([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?

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.