-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreply-submit.php
70 lines (56 loc) · 1.55 KB
/
reply-submit.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
<?php
/**
* Processing POST reply
*
* @author Adam Studenic
*
*/
include 'functions.php';
require_once 'libs/autoload.php';
use Mailgun\Mailgun;
if (isset($_POST)) {
if (isset($_POST["delete"])) {
deleteMessage($_POST["messageId"]);
header("location:mails.php?deleted=TRUE");
} else {
$to = $_POST["to"];
$subject = $_POST["subject"];
$from = $_POST["from"];
$cc = $_POST["cc"];
$bcc = $_POST["bcc"];
$message = $_POST["message"];
$messageId = $_POST["messageId"];
if (!empty($messageId)) {
$arr = array();
$arr["replied"] = 1;
$arr["message"] = json_encode(array("reply" => $message));
$arr['date_create%sql'] = 'NOW()';
updateRow($arr, $messageId);
}
$mg = new Mailgun("key-75wv99jndh25oueyatftijqf09xjk9v5");
$domain = "sandbox7573.mailgun.org";
$mailValues = array('from' => $from,
'to' => $to,
'subject' => $subject,
'text' => $message
);
if ($bcc) {
$mailValues["bcc"] = $bcc;
}
if ($cc) {
$mailValues["cc"] = $cc;
}
$res = $mg->sendMessage($domain, $mailValues);
$sent = "success";
// if($res["success"]){
// $sent = "danger";
// }
if($messageId) {
header("location:reply.php?id=" . $messageId . "&sent=" . $sent);
exit();
} else {
header("location:reply.php?sent=" . $sent);
}
}
}
?>