-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_report.php
More file actions
55 lines (45 loc) · 1.71 KB
/
Copy pathsend_report.php
File metadata and controls
55 lines (45 loc) · 1.71 KB
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
<?php
header('Content-Type: application/json');
ini_set('display_errors', 1);
error_reporting(E_ALL);
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
require 'PHPMailer/src/Exception.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Get POST data
$name = trim($_POST['reporterName'] ?? '');
$email = trim($_POST['reporterEmail'] ?? '');
$description = trim($_POST['incidentDescription'] ?? '');
$contactPermission = isset($_POST['contactPermission']) ? 'Yes' : 'No';
// Basic validation
if (!$name || !$description) {
echo json_encode(['status' => 'error', 'message' => 'Name and description are required.']);
exit;
}
// Compose the email body
$body = "New Incident Report:\n\n";
$body .= "Name: $name\n";
$body .= "Email: $email\n";
$body .= "Contact Permission: $contactPermission\n";
$body .= "Description:\n$description\n";
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'shi3ldmaidens@gmail.com';
$mail->Password = 'gntxvcdacaszpuom'; // your app password
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('shi3ldmaidens@gmail.com', 'Shield Maidens Report');
$mail->addAddress('shi3ldmaidens@gmail.com'); // Send to yourself
$mail->isHTML(false);
$mail->Subject = 'New Incident Report from Website';
$mail->Body = $body;
$mail->send();
echo json_encode(['status' => 'success', 'message' => 'Your report has been sent. Our team will reach out within 12 hours if you gave permission.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Mailer Error: ' . $mail->ErrorInfo]);
}
?>