Skip to content

Instantly share code, notes, and snippets.

@nahidacm
Created October 30, 2014 03:27
Show Gist options
  • Save nahidacm/600ae16afa343d857fd7 to your computer and use it in GitHub Desktop.
Save nahidacm/600ae16afa343d857fd7 to your computer and use it in GitHub Desktop.
PHP Email Testing Script
<?php
if(isset($_POST['submit'])){
$to = $_POST['email_to']; // this is your Email address
$from = $_POST['email_from']; // this is the sender's Email address
$name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
Name: <input type="text" name="name"><br>
From Email: <input type="text" name="email_from"><br>
To Email: <input type="text" name="email_to"><br>
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment