mail() function with several variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TomGeorge
Forum Newbie
Posts: 8
Joined: Fri Jan 17, 2003 5:56 am

mail() function with several variables

Post by TomGeorge »

Hi All,

I have been through the mail() section of php.net and cannot find anything regarding this, so have decided to ask here.

I am using the mail() function, and would like to use it in the context shown below:-

mail("myemail", "subject", "$1 <br> $2 <br> etc etc...", "From: Quiz")

Now, I have varialbes numbered like these all the way from 1-20 as well as variables for a name and email address each on a new line. I cannot find reference to this, so could someone point me in the right direction on how to display each of these variables from the form on a new line?

Thanks :-) 8)

Tom G
inso
Forum Newbie
Posts: 1
Joined: Fri Jan 17, 2003 3:37 pm
Location: Montreal
Contact:

RE: mail() function with several variables

Post by inso »

Hi,

you could do this :

$emailbody = "$blabla1 $blabla2 $blabla3";

and if you want to do it automatically:

if ($blabla1){
$emailbody = "$blabla1";
}
if ($blabla2){
$emailbody .= "$blabla";
}


etc..

You can add email variables in it by separing the email address with ,
Like $emailto = "email@address.com";

$emailto .= ", email1@address.com";


and then

mail("nobody@example.com", "the subject", $emaibody,
"From: webmaster@yourserver.com\r\n"
."Reply-To: webmaster@yourserver.com\r\n");
TomGeorge
Forum Newbie
Posts: 8
Joined: Fri Jan 17, 2003 5:56 am

Post by TomGeorge »

Ah ha! Yep that works just nicely, thanks :-)

Regards

Tom George 8)
Post Reply