-
Notifications
You must be signed in to change notification settings - Fork 13
/
.mailer.php
56 lines (41 loc) · 1.25 KB
/
.mailer.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
<?php
require '.db_config.php';
require_once '.functions.php';
// Data array
$data = array();
// Verification logic
$verifiedTo = isset($_POST['to']) && $_POST['to'] != '';
$verifiedSubject = isset($_POST['subject']) && $_POST['subject'] != '';
$verifiedBody = isset($_POST['body']) && $_POST['body'] != '';
if (!($verifiedTo && $verifiedSubject && $verifiedBody && $_POST['sessionId'])) {
$data['success'] = false;
echo (json_encode($data));
return;
}
$connection = openDatabaseConnection();
if (getUser($_POST['sessionId'], $connection)['admin'] == 0) {
$data['success'] = false;
echo (json_encode($data));
$connection = null;
return;
}
$connection = null;
$url = 'https://mailer.lp13.rpiambulance.com/sendmail';
$ch = curl_init();
$fields = json_encode(array(
'to' => $_POST['to'],
'subject' => $_POST['subject'],
'body' => $_POST['body'],
'token' => $slacktoken
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
echo($result);
?>