forked from hngi/heracles-networth-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.php
61 lines (50 loc) · 2.46 KB
/
mail.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// access
$secretKey = '6LcUkrsUAAAAAD4eaFqnbz1HaQjc5rwUjGBB7i8_';
$captcha = $_POST['g-recaptcha-response'];
// if(!$captcha){
// echo '<p class="alert alert-warning">Please check the the captcha form.</p>';
// exit;
// }
# FIX: Replace this email with recipient email
$mail_to = "olamilekan.adekunle@gmail.com";
# Sender Data
// $subject = trim($_POST["subject"]);
// $name = str_replace(array("\r","\n"),array(" "," ") , strip_tags(trim($_POST["name"])));
// $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
// $phone = trim($_POST["phone"]);
// $message = trim($_POST["message"]);
// if ( empty($name) OR !filter_var($email, FILTER_VALIDATE_EMAIL) OR empty($phone) OR empty($subject) OR empty($message)) {
// # Set a 400 (bad request) response code and exit.
// http_response_code(400);
// echo '<p class="alert alert-warning">Please complete the form and try again.</p>';
// exit;
// }
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
// if(intval($responseKeys["success"]) !== 1) {
// echo '<p class="alert alert-warning">Please check the the captcha form.</p>';
// } else {
// # Mail Content
// $content = "Name: $name\n";
// $content .= "Email: $email\n\n";
// $content .= "Phone: $phone\n";
// $content .= "Message:\n$message\n";
// # email headers.
// $headers = "From: $name <$email>";
// # Send the email.
// $success = mail($mail_to, $subject, $content, $headers);
// if ($success) {
// # Set a 200 (okay) response code.
// http_response_code(200);
// echo '<p class="alert alert-success">Thank You! Your message has been sent.</p>';
// } else {
// # Set a 500 (internal server error) response code.
// http_response_code(500);
// echo '<p class="alert alert-warning">Oops! Something went wrong, we couldnt send your message.</p>';
// }
// }
}
?>