Skip to content

Instantly share code, notes, and snippets.

@matt-west
Created July 25, 2012 09:06
Show Gist options
  • Save matt-west/3175207 to your computer and use it in GitHub Desktop.
Save matt-west/3175207 to your computer and use it in GitHub Desktop.
Simple PHP Mailer Script
<?php
// This check relies on there being an <input> with the name 'submit' in your form.
// i.e. <input type="submit" name="submit">Send Form</input>
if (isset($_POST['submit'])) {
$to = "user@yourwebsite.com"; // Update with email.
$subject = "Application Submission";
// Create new fields here for each field in your form.
// Ideally you would want some validation here too.
$field1 = $_POST['field1'];
$field2 = $_POST['field2'];
$field3 = $_POST['field3'];
$field4 = $_POST['field4'];
$headers = "From: applications@yourwebsite.com\n";
$message = "Field 1: $field1\nField 2: $field2\nField 3: $field3\nField 4: $field4\n";
echo "Form Sent";
mail($to, $subject, $message, $headers);
} else {
echo "Form failed to send. Please contact us directly.";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment