Page 1 of 1

mail() function with several variables

Posted: Fri Jan 17, 2003 3:13 pm
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

RE: mail() function with several variables

Posted: Fri Jan 17, 2003 3:37 pm
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");

Posted: Sat Jan 18, 2003 6:55 am
by TomGeorge
Ah ha! Yep that works just nicely, thanks :-)

Regards

Tom George 8)