How can I edit .php file to e-mail myself?

Long time reader, First time poster. I’m still a newbie when it comes to these things, but I’ve managed to get pretty far. I’m stuck with the following code though.

Its for a contact form.

Where I am edit to put my e-mail address so that I can receive the message left by customers? As mentioned previously, Im new at this and been stuck now for a couple of days. Any help/tips would be greatly appreciated!:slight_smile:


if(!$_POST) exit;

$email = $_POST['email'];

//$error[] = preg_match('/\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\\.-][a-z0-9]+)*)+"."\\\\.[a-z]{2,}"."$",$email )){
	$error.="Invalid email address entered";
if($errors==1) echo $error;
	$values = array ('name','email','message');
	$required = array('name','email','message');
	$your_email = "";
	$email_subject = "New Message: ".$_POST['subject'];
	$email_content = "new message:\
	foreach($values as $key => $value){
		if ($key != 'subject' && $key != 'company') {
		  if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
		$email_content .= $value.': '.$_POST[$value]."\
	if(@mail($your_email,$email_subject,$email_content)) {
		echo 'Message sent!'; 
	} else {
		echo 'ERROR!';


The php manual shows you what I mean.

If you wrote that code and not copied it from somewhere, then I wouldn’t say you’re still a newbie.

You can include your email address as a bcc in the mail() headers or just add another mail() with your email address as the recipient.

My Mistake… I should have mentioned that its from a template I bought a couple of years ago. My php skills are very low. By a BCC in the mail() headers, you mean:


//$error = preg_match(‘/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i’, $_POST[‘MYEMAILADDRESS’])