Forum Moderators: coopster
hopefully this is a simple query. We have a client site with an enquiry form, which sends the mail to an address such as bob@example.com. The recipient's boss wants to get copies of the mails so they can monitor enquiries and ensure they are dealt with promptly. I'm a php novice but I said I'd try to sort that for him. I assume it's possible, but is it as easy as adding bob's boss to the $email_to variable (i.e. $email_to = "bob@example.com, bobsboss@example.com";) or is it more complex than that?
<?phpini_set('sendmail_from', $email_from); /* Sets the "sendmail_from" variable */
$email_to = "bob@example.com";/* sends the email to your email address */
$name =$_POST['name'];/* takes the "name" information from the previous form and sets it as $name */
$company =$_POST['company'];
$telephone =$_POST['telephone'];
$email_from =$_POST['email']; /* takes the "email" information from the previous form and sets it as $email_from */
$email_subject = "Enquiry from webform";/* The subject of your email */
$comments = $_POST['enquiry'];/* takes the "comments" information from the form and sets it as $comments */
$headers =
"From: $email_from .\n";
"Reply-To: $email_from .\n";/* creates email headers, so the email appears to be from the email address filled out in the previous form. */
/* Next we build the message to add to the email */
$message= "Name: ". $name . "\nCompany: ". $company . "\nTelephone: ". $telephone . "\nE-mail: ". $email_from . "\n\nComments: " . $comments; /* the message will contain the name and the comments */
/* Time to send the email */
$sent = mail($email_to, $email_subject, $message, $headers, '-f .$email_from');
if ($sent)
{
/*If sent direct customers to thankyou page */
header( "Location: http://www.example.com/thanks.html" );
} else {
/* If there is an error display an error message */
echo 'There has been an error sending your comments. Please try later.';
}
?>
I'm hoping its straightforward, but I don't want to break the form by experimenting.