Advertisement
Guest User

Email

a guest
Mar 3rd, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2. $errors = '';
  3. $myemail = '[email protected]';//<-----Put Your email address here.
  4. $bccemail = '[email protected]';//<-----Put Your email address here.
  5. if(empty($_POST['name'])  ||
  6.    empty($_POST['email']) ||
  7.    empty($_POST['message']))
  8. {
  9.     $errors .= "\n Error: all fields are required";
  10. }
  11.  
  12. $name = $_POST['name'];
  13. $email_address = $_POST['email'];
  14. $message = $_POST['message'];
  15. $message=stripslashes($message);
  16.  
  17. if (!preg_match(
  18. "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
  19. $email_address))
  20. {
  21.     $errors .= "\n Error: Invalid email address";
  22. }
  23.  
  24. if( empty($errors))
  25. {
  26.     $to = $myemail;
  27.     $email_subject = "Contact form submission: $name";
  28.     $email_body = "You have received a new message. ".
  29.     " Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message";
  30.    
  31.     $headers = "From: $myemail\n";
  32.     $headers .= "Reply-To: $email_address";
  33.     $headers .= "Bcc: $bccemail";
  34.    
  35.     mail($to,$email_subject,$email_body,$headers);
  36.     //redirect to the 'thank you' page
  37.     header('Location: thank_you_for_contacting_us.php');
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement