| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,63 @@ |
| 1 |
+<?php |
|
| 2 |
+/** |
|
| 3 |
+ * Copyright (C) 2021 Double Bastion LLC |
|
| 4 |
+ * |
|
| 5 |
+ * This file is part of Roundpin, which is licensed under the |
|
| 6 |
+ * GNU Affero General Public License Version 3.0. The license terms |
|
| 7 |
+ * are detailed in the "LICENSE.txt" file located in the root directory. |
|
| 8 |
+ */ |
|
| 9 |
+ |
|
| 10 |
+session_start(); |
|
| 11 |
+ |
|
| 12 |
+ // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');
|
|
| 13 |
+ |
|
| 14 |
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {
|
|
| 15 |
+ |
|
| 16 |
+ define('ACCESSCONST', TRUE);
|
|
| 17 |
+ |
|
| 18 |
+ require('db-connect.php');
|
|
| 19 |
+ |
|
| 20 |
+ $username = $_POST['username']; |
|
| 21 |
+ $roundpinhost = $_POST['roundpinhost']; |
|
| 22 |
+ $sendername = $_POST['sendername']; |
|
| 23 |
+ $senderextension = $_POST['senderextension']; |
|
| 24 |
+ $receiveremail = $_POST['receiveremail']; |
|
| 25 |
+ $texttosend = $_POST['texttosend']; |
|
| 26 |
+ |
|
| 27 |
+ // Get the email address of the user who sends the message, from the 'app_users' table |
|
| 28 |
+ $queryprm = $mysqli->prepare("SELECT username, emailaddress FROM app_users WHERE username = ?");
|
|
| 29 |
+ $queryprm->bind_param("s", $username);
|
|
| 30 |
+ $queryprm->execute(); |
|
| 31 |
+ $queryprmres = $queryprm->get_result()->fetch_assoc(); |
|
| 32 |
+ $senderemail = $queryprmres["emailaddress"]; |
|
| 33 |
+ |
|
| 34 |
+ |
|
| 35 |
+ if (filter_var($receiveremail, FILTER_VALIDATE_EMAIL)) {
|
|
| 36 |
+ |
|
| 37 |
+ $subject = "New group message from Roundpin"; |
|
| 38 |
+ $message = $texttosend . "<br><br>________________<br><br>Instant message to group, sent as email by ". $sendername ." (Extension ". $senderextension .") from Roundpin on '". $roundpinhost ."'.<br>"; |
|
| 39 |
+ |
|
| 40 |
+ $messagefin = chunk_split(base64_encode($message)); |
|
| 41 |
+ |
|
| 42 |
+ $headers = "MIME-Version: 1.0" . "\r\n"; |
|
| 43 |
+ $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n"; |
|
| 44 |
+ $headers .= "Content-Transfer-Encoding: base64" . "\r\n"; |
|
| 45 |
+ |
|
| 46 |
+ // Set the email sender |
|
| 47 |
+ $headers .= "From: " . $senderemail . "\r\n"; |
|
| 48 |
+ $headers .= "Reply-To: " . $senderemail . "\r\n"; |
|
| 49 |
+ |
|
| 50 |
+ if (mail($receiveremail, $subject, $messagefin, $headers)) {
|
|
| 51 |
+ $messagetosend = 'success'; |
|
| 52 |
+ } else { $messagetosend = "Error while sending the email!"; }
|
|
| 53 |
+ |
|
| 54 |
+ } else { $messagetosend = "The email address is not valid!"; }
|
|
| 55 |
+ |
|
| 56 |
+ $response = array('result' => $messagetosend);
|
|
| 57 |
+ echo json_encode($response); |
|
| 58 |
+ |
|
| 59 |
+} else {
|
|
| 60 |
+ header("Location: ../login.php");
|
|
| 61 |
+} |
|
| 62 |
+ |
|
| 63 |
+?> |