Forum Moderators: coopster
<?php
$to = "me@me.com";
$name = $_POST['name'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$msg = $_POST['msg'];
$d = date('l dS \of F Y h:i:s A');
$sub = "Contact from website";
$headers = "From:" .$email."\n";
$mes .= "Name: ".$name."\n";
$mes .= "Tel: ".$tel."\n";
$mes .= 'Email: '.$email."\n";
$mes .= "Message: ".$msg."\n";if (empty($name) ¦¦ empty($tel) ¦¦ empty($email) ¦¦ empty($msg))
{
echo " <h3>Sorry all fields are required.</h3>";
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
print " <h3>Sorry the email address you entered looks like it's invalid.</h3>";
}
else
{
$mail = mail("$to", "$sub", "$mes", "$headers");
print " <h3><center>Thank you ".$name." for contacting me.<br>I will get back to you as soon as possible</center></h3>";
}
?>
"Thankyou for contacting me. This is a copy of the email that you have sent and I'll respond as soon as I can."
(Then the body of the email)
I suppose almost like an autoresponse.
Thanks again
just add the Cc to the headers
$to = "me@me.com";
$name = $_POST['name'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$msg = $_POST['msg'];
$d = date('l dS \of F Y h:i:s A');
$sub = "Contact from website";
$headers = "From:" .$email."\r\n";
$headers .= "Cc: $email\r\n";
$mes .= "Name: ".$name."\n";
$mes .= "Tel: ".$tel."\n";
$mes .= 'Email: '.$email."\n";
$mes .= "Message: ".$msg."\n";
you are supposed to use \r\n to separate your headers, not just \n, though I use both
you also don't need to use " around vars, like you do here
$mail = mail("$to", "$sub", "$mes", "$headers");
just throw the vars in there
$mail = mail($to, $sub, $mes, $headers);
Is it possible (I'm sure it must be) for a copy of the same email to be sent to the person who has just filled in the form?
$headers .= "Cc: $email\r\n";
Not a big deal, but if you want to hide the fact the email was copied to someone else, you can do the following:
$headers .= "Bcc: $email\r\n";
Habtom