Skip to content

Instantly share code, notes, and snippets.

@knorthfield
Created November 10, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knorthfield/db45c9bc81a79d822483edfed9a1780c to your computer and use it in GitHub Desktop.
Save knorthfield/db45c9bc81a79d822483edfed9a1780c to your computer and use it in GitHub Desktop.
PHP basic mailer
<?php
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
$message = implode("\n", array_map(function ($v, $k) { return $k . ': ' . $v; }, $_POST, array_keys($_POST)));
$headers = 'From: contact_form@example.com';
mail('info@example.com', 'Website Contact Form', $message, $headers);
header("Location: http://www.example.com/thankyou");
die();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment