Last active
December 16, 2015 19:00
-
-
Save kixxauth/5482124 to your computer and use it in GitHub Desktop.
Contact form email sending in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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