-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendSubscriberEmail.php
39 lines (36 loc) · 1.36 KB
/
sendSubscriberEmail.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
<?php
session_start();
include_once ("Utilities/SessionManager.php");
include_once("Utilities/Mailer.php");
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$responseText = "";
// Check for empty fields
if(empty($_POST['email']) || empty($_POST['subject']) || empty($_POST['message']) || empty($_POST['securityuserid']))
{
$responseText = "Please complete all required fields to send an email.";
return false;
}
else{
$securityUserId = $_POST['securityuserid'];
if($securityUserId > 0 && $securityUserId == SessionManager::getSecurityUserId()){
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$subject = strip_tags(htmlspecialchars($_POST['subject']));
$message = strip_tags(htmlspecialchars($_POST['message']));
// Create the email and send the message
$email_subject = $subject;
$email_body = $message;
if($email_subject != "" && $email_body != "" && $message != ""){
Mailer::sendGenericEmail($email_address,$email_subject,$email_body);
$responseText = "Success Message Sent to ".$email_address;
}
else{
$responseText = "Failed";
}
}
else{
$responseText = "Failed Session Validation";
}
}
echo $responseText;
}
?>