PHP mail question

Hi, I was wondering if it is possible to add 2 mail features into a script. I have it now where the script sends an email to me when the form is submitted. I would like it to also send a confirmation back to the person who sent it. Please advise. Thank you.
//sends email via php to the following address
$mailuser = "";
$replyuser = $_POST['email'];
$replyname = $_POST['name'];
//echo 'default chosen address: '.$mailuser;
	$header = "Return-Path: ".$mailuser."\r\n"; 
	$header .= "From: ".$replyname." <".$replyuser.">\r\n"; 
	$header .= "Content-Type: text/html;"; 
	$interests ="";
      $list = $_POST['interests'];
      foreach($list as $k => $v)
      $interests .= $v . "<br />\n";
	$mail_body = '
	'. $_POST[name] . ' has submitted this information from the Equine Reproduction Concepts website. <br><br>
	Name: '. $_POST[name] . '<br>
	email: '. $_POST[email] . '<br>
	Address: '. $_POST[address] . '<br>
	City: '. $_POST[city] . '<br>
	State: '. $_POST[state] . '<br>
	Zip Code: '. $_POST[zip] . '<br>
	Home Phone Number: '. $_POST[hphone] . '<br>
	Work Phone Number: '. $_POST[wphone] . '<br>
	Fax Number: '. $_POST[fax] . '<br>
	Comments/Questions: '. $_POST[notes] . '<br><br>'. ($interests!="" ?'
      Interests: All of the below were checked as services '. $_POST[name] . ' has interest in.<br> '. $interests : '');
	mail ($mailuser, 'ERC Contact Submission', $mail_body, $header);

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Should be able to do it just by changing to this

$mailuser = ",".$_POST['email'];
Or, you could add another mail() function right below your current that says this, if you want:

mail ($_POST['email'], 'ERC Contact Submission Confirmation', $mail_body, $header);

There are actually several ways to do it

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You might want to create a new $header for the response email - otherwise  the confirmation mail to the user will appear to come from the user themselves.
I suggest using a PHP-Mailer-Class like or which will allow you to extend your script easy and understandable. Also it will protect you script agains Mail_injects and thus acting your server as a spammer which is currently possible with that script.
Loganathan NatarajanLAMP DeveloperCommented:
this is very good example, just try for multiple recipients,
// multiple recipients
$to  = '' . ', '; // note the comma
$to .= '';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
  <title>Birthday Reminders for August</title>
  <p>Here are the birthdays upcoming in August!</p>
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <>, Kelly <>' . "\r\n";
$headers .= 'From: Birthday Reminder <>' . "\r\n";
$headers .= 'Cc:' . "\r\n";
$headers .= 'Bcc:' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.