2014-12-24 11:40:57 -04:00
|
|
|
<?php
|
2019-11-21 15:07:44 -04:00
|
|
|
|
2022-06-20 12:20:37 -04:00
|
|
|
use ProcessMaker\BusinessModel\EmailServer;
|
2019-11-21 15:07:44 -04:00
|
|
|
use ProcessMaker\Core\System;
|
|
|
|
|
use ProcessMaker\GmailOAuth\GmailOAuth;
|
2021-04-29 12:32:54 -04:00
|
|
|
use ProcessMaker\Office365OAuth\Office365OAuth;
|
2019-11-21 15:07:44 -04:00
|
|
|
|
|
|
|
|
$option = (isset($_POST["option"])) ? $_POST["option"] : "";
|
|
|
|
|
$response = [];
|
2014-12-24 11:40:57 -04:00
|
|
|
|
2017-08-09 12:03:25 -04:00
|
|
|
$RBAC->allows(basename(__FILE__), $option);
|
2014-12-24 11:40:57 -04:00
|
|
|
switch ($option) {
|
|
|
|
|
case "INS":
|
2019-11-21 15:07:44 -04:00
|
|
|
$arrayData = [];
|
2014-12-24 11:40:57 -04:00
|
|
|
$server = "";
|
|
|
|
|
$port = "";
|
2018-11-23 14:41:04 -04:00
|
|
|
$incomingServer = "";
|
|
|
|
|
$incomingPort = "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$reqAuthentication = 0;
|
|
|
|
|
$password = "";
|
|
|
|
|
$smtpSecure = "";
|
|
|
|
|
$cboEmailEngine = $_POST["cboEmailEngine"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$fromName = $_POST["fromName"];
|
|
|
|
|
$fromMail = $_POST["fromMail"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$sendTestMail = (int) ($_POST["sendTestMail"]);
|
|
|
|
|
$mailTo = ($sendTestMail == 1) ? $_POST["mailTo"] : "";
|
|
|
|
|
$emailServerDefault = (int) ($_POST["emailServerDefault"]);
|
2014-12-24 11:40:57 -04:00
|
|
|
|
|
|
|
|
if ($cboEmailEngine == "PHPMAILER") {
|
|
|
|
|
$server = $_POST["server"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$port = (int) ($_POST["port"]);
|
|
|
|
|
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
|
|
|
|
|
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$smtpSecure = $_POST["smtpSecure"];
|
2018-11-23 14:41:04 -04:00
|
|
|
} elseif ($cboEmailEngine == "IMAP") {
|
|
|
|
|
$server = $_POST["server"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$port = (int) ($_POST["port"]);
|
2018-11-23 14:41:04 -04:00
|
|
|
$incomingServer = $_POST["incomingServer"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$incomingPort = (int) ($_POST["incomingPort"]);
|
|
|
|
|
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
|
|
|
|
|
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
|
2018-11-23 14:41:04 -04:00
|
|
|
$smtpSecure = $_POST["smtpSecure"];
|
2014-12-24 11:40:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2022-06-20 12:20:37 -04:00
|
|
|
$arrayData = [
|
2019-11-21 15:07:44 -04:00
|
|
|
"MESS_ENGINE" => $cboEmailEngine,
|
|
|
|
|
"MESS_SERVER" => $server,
|
|
|
|
|
"MESS_PORT" => $port,
|
|
|
|
|
"MESS_INCOMING_SERVER" => $incomingServer,
|
|
|
|
|
"MESS_INCOMING_PORT" => $incomingPort,
|
|
|
|
|
"MESS_RAUTH" => $reqAuthentication,
|
|
|
|
|
"MESS_ACCOUNT" => $accountFrom,
|
|
|
|
|
"MESS_PASSWORD" => $password,
|
|
|
|
|
"MESS_FROM_MAIL" => $fromMail,
|
|
|
|
|
"MESS_FROM_NAME" => $fromName,
|
|
|
|
|
"SMTPSECURE" => $smtpSecure,
|
2014-12-24 11:40:57 -04:00
|
|
|
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
2019-11-21 15:07:44 -04:00
|
|
|
"MAIL_TO" => $mailTo,
|
|
|
|
|
"MESS_DEFAULT" => $emailServerDefault
|
2022-06-20 12:20:37 -04:00
|
|
|
];
|
2014-12-24 11:40:57 -04:00
|
|
|
|
2022-06-20 12:20:37 -04:00
|
|
|
$emailSever = new EmailServer();
|
2014-12-24 11:40:57 -04:00
|
|
|
$arrayEmailServerData = $emailSever->create($arrayData);
|
2022-06-20 12:20:37 -04:00
|
|
|
// Register the log
|
|
|
|
|
G::auditLog(
|
|
|
|
|
"CreateEmailSettings",
|
|
|
|
|
"SetDefaultConfiguration-> " . $emailServerDefault .
|
|
|
|
|
", EmailEngine-> " . $cboEmailEngine .
|
|
|
|
|
", Server-> " . $server .
|
|
|
|
|
", Port-> " . $port .
|
|
|
|
|
", RequireAuthentication-> " . $reqAuthentication .
|
|
|
|
|
", FromMail-> " . $fromMail .
|
|
|
|
|
", FromName-> " . $fromName .
|
|
|
|
|
", UseSecureConnection-> " . $smtpSecure
|
|
|
|
|
);
|
2014-12-24 11:40:57 -04:00
|
|
|
|
|
|
|
|
$response["status"] = "OK";
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["data"] = $arrayEmailServerData;
|
2014-12-24 11:40:57 -04:00
|
|
|
} catch (Exception $e) {
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["status"] = "ERROR";
|
2014-12-24 11:40:57 -04:00
|
|
|
$response["message"] = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "UPD":
|
2019-11-21 15:07:44 -04:00
|
|
|
$arrayData = [];
|
2014-12-24 11:40:57 -04:00
|
|
|
$emailServerUid = $_POST["emailServerUid"];
|
|
|
|
|
$server = "";
|
|
|
|
|
$port = "";
|
2018-11-23 14:41:04 -04:00
|
|
|
$incomingServer = "";
|
|
|
|
|
$incomingPort = "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$reqAuthentication = 0;
|
|
|
|
|
$password = "";
|
|
|
|
|
$smtpSecure = "";
|
|
|
|
|
$cboEmailEngine = $_POST["cboEmailEngine"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$fromName = $_POST["fromName"];
|
|
|
|
|
$fromMail = $_POST["fromMail"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$sendTestMail = (int) ($_POST["sendTestMail"]);
|
|
|
|
|
$mailTo = ($sendTestMail == 1) ? $_POST["mailTo"] : "";
|
|
|
|
|
$emailServerDefault = (int) ($_POST["emailServerDefault"]);
|
2014-12-24 11:40:57 -04:00
|
|
|
|
|
|
|
|
if ($cboEmailEngine == "PHPMAILER") {
|
|
|
|
|
$server = $_POST["server"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$port = (int) ($_POST["port"]);
|
|
|
|
|
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
|
|
|
|
|
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$smtpSecure = $_POST["smtpSecure"];
|
2018-11-23 14:41:04 -04:00
|
|
|
} elseif ($cboEmailEngine == "IMAP") {
|
|
|
|
|
$server = $_POST["server"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$port = (int) ($_POST["port"]);
|
2018-11-23 14:41:04 -04:00
|
|
|
$incomingServer = $_POST["incomingServer"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$incomingPort = (int) ($_POST["incomingPort"]);
|
|
|
|
|
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
|
|
|
|
|
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
|
2018-11-23 14:41:04 -04:00
|
|
|
$smtpSecure = $_POST["smtpSecure"];
|
2014-12-24 11:40:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2022-06-20 12:20:37 -04:00
|
|
|
$arrayData = [
|
2019-11-21 15:07:44 -04:00
|
|
|
"MESS_ENGINE" => $cboEmailEngine,
|
|
|
|
|
"MESS_SERVER" => $server,
|
|
|
|
|
"MESS_PORT" => $port,
|
|
|
|
|
"MESS_INCOMING_SERVER" => $incomingServer,
|
|
|
|
|
"MESS_INCOMING_PORT" => $incomingPort,
|
|
|
|
|
"MESS_RAUTH" => $reqAuthentication,
|
|
|
|
|
"MESS_ACCOUNT" => $accountFrom,
|
|
|
|
|
"MESS_PASSWORD" => $password,
|
|
|
|
|
"MESS_FROM_MAIL" => $fromMail,
|
|
|
|
|
"MESS_FROM_NAME" => $fromName,
|
|
|
|
|
"SMTPSECURE" => $smtpSecure,
|
2014-12-24 11:40:57 -04:00
|
|
|
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
2019-11-21 15:07:44 -04:00
|
|
|
"MAIL_TO" => $mailTo,
|
|
|
|
|
"MESS_DEFAULT" => $emailServerDefault
|
2022-06-20 12:20:37 -04:00
|
|
|
];
|
2014-12-24 11:40:57 -04:00
|
|
|
|
2022-06-20 12:20:37 -04:00
|
|
|
$emailSever = new EmailServer();
|
2014-12-24 11:40:57 -04:00
|
|
|
$arrayEmailServerData = $emailSever->update($emailServerUid, $arrayData);
|
2022-06-20 12:20:37 -04:00
|
|
|
// Register the log
|
|
|
|
|
G::auditLog(
|
|
|
|
|
"UpdateEmailSettings",
|
|
|
|
|
"EmailServer-> " . $emailServerUid .
|
|
|
|
|
", SetDefaultConfiguration-> " . $emailServerDefault .
|
|
|
|
|
", EmailEngine-> " . $cboEmailEngine .
|
|
|
|
|
", Server-> " . $server .
|
|
|
|
|
", Port-> " . $port .
|
|
|
|
|
", RequireAuthentication-> " . $reqAuthentication .
|
|
|
|
|
", FromMail-> " . $fromMail .
|
|
|
|
|
", FromName-> " . $fromName .
|
|
|
|
|
", UseSecureConnection-> " . $smtpSecure
|
|
|
|
|
);
|
2014-12-24 11:40:57 -04:00
|
|
|
|
|
|
|
|
$response["status"] = "OK";
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["data"] = $arrayEmailServerData;
|
2014-12-24 11:40:57 -04:00
|
|
|
} catch (Exception $e) {
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["status"] = "ERROR";
|
2014-12-24 11:40:57 -04:00
|
|
|
$response["message"] = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "DEL":
|
|
|
|
|
$emailServerUid = $_POST["emailServerUid"];
|
|
|
|
|
|
|
|
|
|
try {
|
2022-06-20 12:20:37 -04:00
|
|
|
$emailSever = new EmailServer();
|
2014-12-24 11:40:57 -04:00
|
|
|
$result = $emailSever->delete($emailServerUid);
|
2022-06-20 12:20:37 -04:00
|
|
|
// Register the log
|
|
|
|
|
G::auditLog(
|
|
|
|
|
"DeleteEmailSettings",
|
|
|
|
|
"EmailServer-> " . $emailServerUid
|
|
|
|
|
);
|
2014-12-24 11:40:57 -04:00
|
|
|
|
|
|
|
|
$response["status"] = "OK";
|
|
|
|
|
} catch (Exception $e) {
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["status"] = "ERROR";
|
2014-12-24 11:40:57 -04:00
|
|
|
$response["message"] = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "LST":
|
|
|
|
|
$pageSize = $_POST["pageSize"];
|
|
|
|
|
$search = $_POST["search"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$sortField = (isset($_POST["sort"])) ? $_POST["sort"] : "";
|
|
|
|
|
$sortDir = (isset($_POST["dir"])) ? $_POST["dir"] : "";
|
|
|
|
|
$start = (isset($_POST["start"])) ? $_POST["start"] : 0;
|
|
|
|
|
$limit = (isset($_POST["limit"])) ? $_POST["limit"] : $pageSize;
|
2014-12-24 11:40:57 -04:00
|
|
|
|
|
|
|
|
try {
|
2022-06-20 12:20:37 -04:00
|
|
|
$emailSever = new EmailServer();
|
|
|
|
|
$result = $emailSever->getEmailServers(["filter" => $search], $sortField, $sortDir, $start, $limit);
|
2014-12-24 11:40:57 -04:00
|
|
|
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["status"] = "OK";
|
2014-12-24 11:40:57 -04:00
|
|
|
$response["success"] = true;
|
|
|
|
|
$response["resultTotal"] = $result["total"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["resultRoot"] = $result["data"];
|
2014-12-24 11:40:57 -04:00
|
|
|
} catch (Exception $e) {
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["status"] = "ERROR";
|
2014-12-24 11:40:57 -04:00
|
|
|
$response["message"] = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "TEST":
|
2019-11-21 15:07:44 -04:00
|
|
|
$arrayData = [];
|
2014-12-24 11:40:57 -04:00
|
|
|
|
|
|
|
|
$server = "";
|
|
|
|
|
$port = "";
|
2018-11-23 14:41:04 -04:00
|
|
|
$incomingServer = "";
|
|
|
|
|
$incomingPort = "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$reqAuthentication = 0;
|
|
|
|
|
$password = "";
|
|
|
|
|
$smtpSecure = "";
|
|
|
|
|
|
|
|
|
|
$cboEmailEngine = $_POST["cboEmailEngine"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$accountFrom = (isset($_POST["accountFrom"])) ? $_POST["accountFrom"] : "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$fromName = $_POST["fromName"];
|
|
|
|
|
$fromMail = $_POST["fromMail"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$sendTestMail = (int) ($_POST["sendTestMail"]);
|
|
|
|
|
$mailTo = ($sendTestMail == 1) ? $_POST["mailTo"] : "";
|
|
|
|
|
$emailServerDefault = (int) ($_POST["emailServerDefault"]);
|
2014-12-24 11:40:57 -04:00
|
|
|
|
2018-11-23 14:41:04 -04:00
|
|
|
if ($cboEmailEngine == "PHPMAILER" || $cboEmailEngine == "IMAP") {
|
2014-12-24 11:40:57 -04:00
|
|
|
$server = $_POST["server"];
|
2019-11-21 15:07:44 -04:00
|
|
|
$port = (int) ($_POST["port"]);
|
|
|
|
|
$reqAuthentication = (int) ($_POST["reqAuthentication"]);
|
|
|
|
|
$password = ($reqAuthentication == 1) ? $_POST["password"] : "";
|
2014-12-24 11:40:57 -04:00
|
|
|
$smtpSecure = $_POST["smtpSecure"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2022-06-20 12:20:37 -04:00
|
|
|
$arrayData = [
|
2019-11-21 15:07:44 -04:00
|
|
|
"MESS_ENGINE" => $cboEmailEngine,
|
|
|
|
|
"MESS_SERVER" => $server,
|
|
|
|
|
"MESS_PORT" => $port,
|
|
|
|
|
"MESS_RAUTH" => $reqAuthentication,
|
|
|
|
|
"MESS_ACCOUNT" => $accountFrom,
|
|
|
|
|
"MESS_PASSWORD" => $password,
|
|
|
|
|
"MESS_FROM_MAIL" => $fromMail,
|
|
|
|
|
"MESS_FROM_NAME" => $fromName,
|
|
|
|
|
"SMTPSECURE" => $smtpSecure,
|
2014-12-24 11:40:57 -04:00
|
|
|
"MESS_TRY_SEND_INMEDIATLY" => $sendTestMail,
|
2019-11-21 15:07:44 -04:00
|
|
|
"MAIL_TO" => $mailTo,
|
|
|
|
|
"MESS_DEFAULT" => $emailServerDefault
|
2022-06-20 12:20:37 -04:00
|
|
|
];
|
2014-12-24 11:40:57 -04:00
|
|
|
|
2022-06-20 12:20:37 -04:00
|
|
|
$emailSever = new EmailServer();
|
2014-12-24 11:40:57 -04:00
|
|
|
$arrayEmailServerData = $emailSever->testConnection($arrayData);
|
|
|
|
|
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["data"] = $arrayEmailServerData;
|
2014-12-24 11:40:57 -04:00
|
|
|
} catch (Exception $e) {
|
2019-11-21 15:07:44 -04:00
|
|
|
$response["status"] = "ERROR";
|
2014-12-24 11:40:57 -04:00
|
|
|
$response["message"] = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2019-11-21 15:07:44 -04:00
|
|
|
case "createAuthUrl":
|
|
|
|
|
try {
|
|
|
|
|
$gmailOAuth = new GmailOAuth();
|
2021-04-29 12:32:54 -04:00
|
|
|
$gmailOAuth->setServer($_POST['server']);
|
|
|
|
|
$gmailOAuth->setPort($_POST['port']);
|
2019-11-21 15:07:44 -04:00
|
|
|
$gmailOAuth->setClientID($_POST['clientID']);
|
|
|
|
|
$gmailOAuth->setClientSecret($_POST['clientSecret']);
|
|
|
|
|
$gmailOAuth->setRedirectURI(System::getServerMainPath() . "/emailServer/emailServerGmailOAuth");
|
|
|
|
|
$gmailOAuth->setEmailEngine($_POST['emailEngine']);
|
|
|
|
|
$gmailOAuth->setFromAccount($_POST['fromAccount']);
|
|
|
|
|
$gmailOAuth->setSenderEmail($_POST['senderEmail']);
|
|
|
|
|
$gmailOAuth->setSenderName($_POST['senderName']);
|
|
|
|
|
$gmailOAuth->setSendTestMail((int) $_POST['sendTestMail']);
|
|
|
|
|
$gmailOAuth->setMailTo($_POST['mailTo']);
|
|
|
|
|
$gmailOAuth->setSetDefaultConfiguration((int) $_POST['setDefaultConfiguration']);
|
2022-07-08 10:36:00 -04:00
|
|
|
// Audit log parameters
|
|
|
|
|
$action = "CreateEmailSettings";
|
|
|
|
|
$content = "SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
|
2019-11-21 15:07:44 -04:00
|
|
|
if (!empty($_POST['emailServerUid'])) {
|
|
|
|
|
$gmailOAuth->setEmailServerUid($_POST['emailServerUid']);
|
2022-07-08 10:36:00 -04:00
|
|
|
// Audit log parameters
|
|
|
|
|
$action = "UpdateEmailSettings";
|
|
|
|
|
$content = "EmailServer-> " . $_POST['emailServerUid'] .
|
|
|
|
|
", SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
|
2019-11-21 15:07:44 -04:00
|
|
|
}
|
|
|
|
|
$client = $gmailOAuth->getGoogleClient();
|
2022-07-08 10:36:00 -04:00
|
|
|
// Register the log
|
|
|
|
|
G::auditLog(
|
|
|
|
|
$action,
|
|
|
|
|
$content .
|
|
|
|
|
", EmailEngine-> " . $_POST['emailEngine'] .
|
|
|
|
|
", Server-> " . $_POST['server'] .
|
|
|
|
|
", Port-> " . $_POST['port'] .
|
|
|
|
|
", FromMail-> " . $_POST['senderEmail'] .
|
|
|
|
|
", FromName-> " . $_POST['senderName']
|
|
|
|
|
);
|
2019-11-21 15:07:44 -04:00
|
|
|
$response = [
|
|
|
|
|
"status" => 200,
|
|
|
|
|
"data" => $client->createAuthUrl()
|
|
|
|
|
];
|
|
|
|
|
$_SESSION['gmailOAuth'] = $gmailOAuth;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response = [
|
|
|
|
|
"status" => 500,
|
|
|
|
|
"message" => $e->getMessage()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
break;
|
2021-04-29 12:32:54 -04:00
|
|
|
case "createAuthUrlOffice365":
|
|
|
|
|
try {
|
|
|
|
|
$office365OAuth = new Office365OAuth();
|
|
|
|
|
$office365OAuth->setServer($_POST['server']);
|
|
|
|
|
$office365OAuth->setPort($_POST['port']);
|
|
|
|
|
$office365OAuth->setClientID($_POST['clientID']);
|
|
|
|
|
$office365OAuth->setClientSecret($_POST['clientSecret']);
|
|
|
|
|
$office365OAuth->setRedirectURI(System::getServerMainPath() . "/emailServer/emailServerOffice365OAuth");
|
|
|
|
|
$office365OAuth->setEmailEngine($_POST['emailEngine']);
|
|
|
|
|
$office365OAuth->setFromAccount($_POST['fromAccount']);
|
|
|
|
|
$office365OAuth->setSenderEmail($_POST['senderEmail']);
|
|
|
|
|
$office365OAuth->setSenderName($_POST['senderName']);
|
|
|
|
|
$office365OAuth->setSendTestMail((int) $_POST['sendTestMail']);
|
|
|
|
|
$office365OAuth->setMailTo($_POST['mailTo']);
|
|
|
|
|
$office365OAuth->setSetDefaultConfiguration((int) $_POST['setDefaultConfiguration']);
|
2022-07-08 10:36:00 -04:00
|
|
|
// Audit log parameters
|
|
|
|
|
$action = "CreateEmailSettings";
|
|
|
|
|
$content = "SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
|
2021-04-29 12:32:54 -04:00
|
|
|
if (!empty($_POST['emailServerUid'])) {
|
|
|
|
|
$office365OAuth->setEmailServerUid($_POST['emailServerUid']);
|
2022-07-08 10:36:00 -04:00
|
|
|
// Audit log parameters
|
|
|
|
|
$action = "UpdateEmailSettings";
|
|
|
|
|
$content = "EmailServer-> " . $_POST['emailServerUid'] .
|
|
|
|
|
", SetDefaultConfiguration-> " . $_POST['setDefaultConfiguration'];
|
2021-04-29 12:32:54 -04:00
|
|
|
}
|
|
|
|
|
$client = $office365OAuth->getOffice365Client();
|
2022-07-08 10:36:00 -04:00
|
|
|
// Register the log
|
|
|
|
|
G::auditLog(
|
|
|
|
|
$action,
|
|
|
|
|
$content .
|
|
|
|
|
", EmailEngine-> " . $_POST['emailEngine'] .
|
|
|
|
|
", Server-> " . $_POST['server'] .
|
|
|
|
|
", Port-> " . $_POST['port'] .
|
|
|
|
|
", FromMail-> " . $_POST['senderEmail'] .
|
|
|
|
|
", FromName-> " . $_POST['senderName']
|
|
|
|
|
);
|
2021-04-29 12:32:54 -04:00
|
|
|
$response = [
|
|
|
|
|
"status" => 200,
|
|
|
|
|
"data" => $client->getAuthorizationUrl($office365OAuth->getOptions())
|
|
|
|
|
];
|
|
|
|
|
$_SESSION['office365OAuth'] = $office365OAuth;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$response = [
|
|
|
|
|
"status" => 500,
|
|
|
|
|
"message" => $e->getMessage()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-12-24 11:40:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo G::json_encode($response);
|