Skip to content

Instantly share code, notes, and snippets.

@scragz
Created January 21, 2011 00:40
Show Gist options
  • Save scragz/789030 to your computer and use it in GitHub Desktop.
Save scragz/789030 to your computer and use it in GitHub Desktop.
<?php
$validation_error = false;
if (array_key_exists('submit', $_POST)) {
if (
!strlen($_POST['contact_name']) ||
!strlen($_POST['contact_email']) ||
!strlen($_POST['contact_message'])
) {
$validation_error = 'Please complete all required fields.';
} else {
$email_body = <<<EOF
New contact received from scragz.com.
Name: {$_POST['contact_name']}
Email: {$_POST['contact_email']}
Phone: {$_POST['contact_phone']}
Message:
{$_POST['contact_message']}
EOF;
$to = '[email protected]';
$subject = 'New contact received from x.com';
$message = wordwrap($email_body, 70);
$headers = "From: [email protected]\r\n" .
"Reply-To: {$_POST['contact_email']}\r\n" .
"X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment