forked from cedrickjames/helpdesk-production
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_sendrequest.php
155 lines (84 loc) · 3.25 KB
/
_sendrequest.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!-- session for who is login user -->
<?php
//Set the session timeout for 1 hour
$timeout = 500;
//Set the maxlifetime of the session
ini_set( "session.gc_maxlifetime", $timeout );
//Set the cookie lifetime of the session
ini_set( "session.cookie_lifetime", $timeout );
// session_start();
$s_name = session_name();
$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 500; URL=$url1");
//Check the session exists or not
if(isset( $_COOKIE[ $s_name ] )) {
setcookie( $s_name, $_COOKIE[ $s_name ], time() + $timeout, '/' );
}
else
echo "Session is expired.<br/>";
// end of session timeout>";
session_start();
if(!isset($_SESSION['connected'])){
header("location: index.php");
}
// connection php and transfer of session
include ("includes/connect.php");
$user_dept = $_SESSION['department'];
$user_level=$_SESSION['level'];
?>
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
session_start();
if(isset($_POST['send'])){
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$filename = $_FILES['attachment']['name'];
$location = 'attachment/' . $filename;
move_uploaded_file($_FILES['attachment']['tmp_name'], $location);
//Load composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.glorylocal.com.ph'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // Your Email/ Server Email
$mail->Password = 'C0nn3ctm387'; // Your Password
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
//Send Email
$mail->setFrom('[email protected]'); //eto ang mag front [email protected]
//Recipients
$mail->addAddress($email);
$mail->addReplyTo('[email protected]');
//Attachment
if(!empty($filename)){
$mail->addAttachment($location, $filename);
}
//Content
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->send();
$_SESSION['message'] = 'Message has been sent';
} catch (Exception $e) {
$_SESSION['message'] = 'Message could not be sent. Mailer Error: '.$mail->ErrorInfo;
}
header('location:index.php');
}
else{
$_SESSION['message'] = 'Please fill up the form first';
header('location:index.php');
}