-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
30 lines (25 loc) · 923 Bytes
/
Copy pathsend.php
File metadata and controls
30 lines (25 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
function is_ajax() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
}
if(is_ajax()) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$header = 'From: ' . $email . "\r\n";
$header .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
$header .= 'Mime-Version: 1.0 \r\n';
$header .= 'Content-Type: text/plain';
$bodyMessage = "This message was sent by: " . $name . "\r\n";
$bodyMessage .= "Email: " . $email . "\r\n";
$bodyMessage .= "Message: " . $message . "\r\n";
$for = "carloshclessa@gmail.com";
$subject = "Contact from website";
mail($for, $subject, utf8_encode($bodyMessage), $header );
echo json_encode(array(
'message' => sprintf('Your Message has been sent!')
));
} else {
die("That's not allowed!!");
}
?>