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 = "email@emailhere.com";
$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

pertrai1Asked:
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.

darron_chapmanCommented:
Should be able to do it just by changing to this

$mailuser = "email@emailhere.com,".$_POST['email'];
0
darron_chapmanCommented:
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
0

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
almilyoCommented:
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.
0
hernst42Commented:
I suggest using a PHP-Mailer-Class like http://phpmailer.sf.net or http://swiftmailer.sf.net 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.
0
Loganathan NatarajanLAMP DeveloperCommented:
this is very good example, just try for multiple recipients,
<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
 
// subject
$subject = 'Birthday Reminders for August';
 
// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';
 
// 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 <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
 
// Mail it
mail($to, $subject, $message, $headers);
?> 

Open in new window

0
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
PHP

From novice to tech pro — start learning today.