Skip to content

Instantly share code, notes, and snippets.

@joeyblake
Created December 13, 2011 15:49
Show Gist options
  • Save joeyblake/1472625 to your computer and use it in GitHub Desktop.
Save joeyblake/1472625 to your computer and use it in GitHub Desktop.
simple php form mail
<?php
/* These are the variable that tell the subject of the email and where the email will be sent.*/
$emailSubject = 'Customer Has a Question!';
$mailto = '[email protected]';
/* These will gather what the user has typed into the fieled. */
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$questionField = $_POST['question'];
/* This takes the information and lines it up the way you want it to be sent in the email. */
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Question: $question <br>
EOD;
$headers = "From: $email\r\n"; // This takes the email and displays it as who this email is from.
$headers .= "Content-type: text/html\r\n"; // This tells the server to turn the coding into the text.
$success = mail($mailto, $emailSubject, $body, $headers); // This tells the server what to send.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment