Here it is:
PHP Code:
<?php
include('includes/functions.php');
$myemail = "name@mail.com"; // Edit this with your email address
$mysubj = "New User"; // Set the subject of mail that you will receive from users
if ($_POST["action"] == "send"){
if ($_POST[naam] != " je naam" and $_POST[naam] != "" and $_POST[email] != " je e-mail adres" and $_POST[email] != "" and $_POST[bericht] != "") {
mail ("info@domain.com", "via site",
"
Naam: ".$_POST['naam']."
E-mail: ".$_POST['email']."
Bericht: ".$_POST['bericht']."
",
"From: ".$_POST['naam']." <".$_POST['email'].">");
$subject = "your message to";
$msg = "
Dear $_POST[naam],
Thanks for your message. Will get back to you shortly.
This was your message:
$_POST[bericht]
";
if(checkEmail($_POST['email']))
{
mail($_POST[email], $subject, $msg);
mail($myemail, $mysubj, $_POST['email']); // Sends the mail to you
}
else
die('Invalid Email');
echo 'thanks for your feedback !';
}
else{
echo 'please fill in all fields';
}
}
?>
checkEmail function:
PHP Code:
function validEmail($email)
{
if(!preg_match('/^[^0-9][A-z0-9_-]+[@][A-z0-9_-]+([.][A-z0-9_-]+)*[.][A-z]{2,4}$/',$email))
return false;
else
return true;
}
Put the function in an includes file somewhere, like "includes/functions.php". If for whatever reason you don't / can't do this then just copy the function straight into the top of the page.
Found the checkMail function through google but it seems to work well enough. It doesn't check for DNS records but I mean as you said your not expecting 1000s of subscribers and people potentially makings bots to spam your site, for what you want it should be sufficient
You could always have the $mysubj variable dynamic, but I don't know how you want it done, so I've just left it as it is.
Good Luck
Bookmarks