Skip to content

Instantly share code, notes, and snippets.

@kixxauth
Last active December 16, 2015 19:00
Show Gist options
  • Save kixxauth/5482124 to your computer and use it in GitHub Desktop.
Save kixxauth/5482124 to your computer and use it in GitHub Desktop.
Contact form email sending in PHP
<?php
// If there were *no* submission errors:
if ($err === 0) {
if (function_exists('htmlspecialchars_decode')) {
$subject = htmlspecialchars_decode($subject);
$message = htmlspecialchars_decode($message);
}
$message .= "\r\nPhoneNumber: " . $phone;
$headers = "Content-type: text/plain; charset=UTF-8\r\n";
$headers .= "From: " . $name . "<" . $email . ">\r\n";
$headers .= "Reply-To: $email" . "\r\n";
mail(MAILTO, SUBJECT_PREFIX . " - " . $subject, $message, $headers);
// Return the 'noscript' response.
if (empty($_POST['js'])) {
readfile(CONFIRM_PAGE);
}
// Return the Ajax response.
else {
echo 'OK:' . CONFIRM_PAGE;
}
}
// There was a submission error:
else {
// Return the 'noscript' response.
if (empty($_POST['js'])) {
echo $html_error_page_header . $err . $html_error_page_footer;
}
// Return the Ajax response.
else {
echo $err;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment