Click to See Complete Forum and Search --> : please check mail() code


awebb
07-12-2003, 11:24 AM
I am getting TWO emails when the user sends the form info.
One has the fields but no info and the other is correct.
My host tells me the code is "incorrect".
Could anyone tell me if I have made a mistake?
Here is the mail() code:

/* emailing info, first set variables*/
$fname=$HTTP_POST_VARS['firstname'];
$lname=$HTTP_POST_VARS['lastname'];
$startdate1=$HTTP_POST_VARS['startdate1'];
$startdate2=$HTTP_POST_VARS['startdate2'];
$startdate3=$HTTP_POST_VARS['startdate3'];
$startdate4=$HTTP_POST_VARS['startdate4'];
$email=$HTTP_POST_VARS['email'];
$to='webmaster@chinchall.com, admin@chinchall.com';
$subject='Clouseau Booking';
/* The body text */
$content= 'Name: '.$fname.' '.$lname."\n"
.'Week1: '.$startdate1."\n"
.'Week2: '.$startdate2."\n"
.'Week3: '.$startdate3."\n"
.'Week4: '.$startdate4."\n"
.'Email: '.$email."\n";
/* send the info */
mail ($to, $subject, $content);

Any guidance gratefully received.
Andy

AdamBrill
07-12-2003, 12:42 PM
Are you getting one e-mail at webmaster@chinchall.com and one at admin@chinchall.com? If so, my guess is because you have both addresses in this line:

$to='webmaster@chinchall.com, admin@chinchall.com';

Delete one out and see what happens. :)

awebb
07-13-2003, 01:19 AM
I was unclear in explaining the problem.
BOTH the addresses are getting TWO emails, one empty the other correctly filled.
From what I understand you can put as many addresses as you like in the $to as long as they are separated by ','.
I have also deliberately not included any header info as I thought his was only necessary for complex ie MIME type/HTML mail.
I am sending text only.
I have also tried what I believe to be the simplest possible construction by sending:
mail("webmaster@chinchall.com", "Subject", "Message")
and I got that twice, though at least the message "Message" was in both of them!
Andy