PMC-1375
This commit is contained in:
@@ -510,6 +510,7 @@ class SpoolRun
|
||||
case 'MAIL':
|
||||
case 'PHPMAILER':
|
||||
case 'IMAP':
|
||||
case 'GMAILAPI':
|
||||
switch ($this->config['MESS_ENGINE']) {
|
||||
case 'MAIL':
|
||||
$phpMailer = new PHPMailer();
|
||||
@@ -520,6 +521,11 @@ class SpoolRun
|
||||
$phpMailer = new PHPMailer(true);
|
||||
$phpMailer->Mailer = 'smtp';
|
||||
break;
|
||||
case 'GMAILAPI':
|
||||
$phpMailer = new PHPMailerOAuth();
|
||||
$phpMailer->AuthType = 'XOAUTH2';
|
||||
$phpMailer->isSMTP();
|
||||
break;
|
||||
}
|
||||
|
||||
$phpMailer->SMTPAuth = (isset($this->config['SMTPAuth']) ? $this->config['SMTPAuth'] : '');
|
||||
@@ -529,6 +535,7 @@ class SpoolRun
|
||||
break;
|
||||
case 'IMAP':
|
||||
case 'PHPMAILER':
|
||||
case 'GMAILAPI':
|
||||
//Posible Options for SMTPSecure are: "", "ssl" or "tls"
|
||||
if (isset($this->config['SMTPSecure']) && preg_match('/^(ssl|tls)$/', $this->config['SMTPSecure'])) {
|
||||
$phpMailer->SMTPSecure = $this->config['SMTPSecure'];
|
||||
@@ -543,8 +550,15 @@ class SpoolRun
|
||||
$phpMailer->Encoding = "8bit";
|
||||
$phpMailer->Host = $this->config['MESS_SERVER'];
|
||||
$phpMailer->Port = $this->config['MESS_PORT'];
|
||||
if ($this->config['MESS_ENGINE'] !== 'GMAILAPI') {
|
||||
$phpMailer->Username = $this->config['MESS_ACCOUNT'];
|
||||
$phpMailer->Password = $this->config['MESS_PASSWORD'];
|
||||
} else {
|
||||
$phpMailer->oauthUserEmail = $this->config['MESS_ACCOUNT'];
|
||||
$phpMailer->oauthClientId = $this->config['OAUTH_CLIENT_ID'];
|
||||
$phpMailer->oauthClientSecret = $this->config['OAUTH_CLIENT_SECRET'];
|
||||
$phpMailer->oauthRefreshToken = $this->config['OAUTH_REFRESH_TOKEN'];
|
||||
}
|
||||
|
||||
//From
|
||||
$phpMailer->SetFrom($this->fileData['from_email'], utf8_decode($this->fileData['from_name']));
|
||||
|
||||
@@ -931,7 +931,9 @@ function getEmailConfiguration ()
|
||||
* @param array | $attachments = [] | Attachment | An Optional arrray. An array of files (full paths) to be attached to the email.
|
||||
* @param boolean | $showMessage = true | Show message | Optional parameter. Set to TRUE to show the message in the case's message history.
|
||||
* @param int | $delIndex = 0 | Delegation index of the case | Optional parameter. The delegation index of the current task in the case.
|
||||
* @param array | $config = [] | Email server configuration | An optional array: An array of parameters to be used in the Email sent (MESS_ENGINE, MESS_SERVER, MESS_PORT, MESS_FROM_MAIL, MESS_RAUTH, MESS_ACCOUNT, MESS_PASSWORD, and SMTPSecure) Or String: UID of Email server .
|
||||
* @param array | $config = [] | Email server configuration | An optional array: An array of parameters to be used in the Email sent (MESS_ENGINE,
|
||||
* MESS_SERVER, MESS_PORT, MESS_FROM_MAIL, MESS_RAUTH, MESS_ACCOUNT, MESS_PASSWORD, SMTPSecure, OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET and OAUTH_REFRESH_TOKEN)
|
||||
* Or String: UID of Email server .
|
||||
* @return int | | result | Result of sending email
|
||||
*
|
||||
* @see class.pmFunctions::PMFSendMessageToGroup()
|
||||
|
||||
@@ -817,7 +817,10 @@ switch (($_POST['action']) ? $_POST['action'] : $_REQUEST['action']) {
|
||||
'MESS_ACCOUNT' => $aSetup['MESS_ACCOUNT'],
|
||||
'MESS_PASSWORD' => $aSetup['MESS_PASSWORD'],
|
||||
'SMTPSecure' => $aSetup['SMTPSecure'],
|
||||
'SMTPAuth' => $aSetup['MESS_RAUTH']
|
||||
'SMTPAuth' => $aSetup['MESS_RAUTH'],
|
||||
'OAUTH_CLIENT_ID' => $aSetup['OAUTH_CLIENT_ID'],
|
||||
'OAUTH_CLIENT_SECRET' => $aSetup['OAUTH_CLIENT_SECRET'],
|
||||
'OAUTH_REFRESH_TOKEN' => $aSetup['OAUTH_REFRESH_TOKEN']
|
||||
)
|
||||
);
|
||||
$oSpool->create(array('msg_uid' => $data['MSG_UID'], 'app_uid' => $data['APP_UID'], 'del_index' => $data['DEL_INDEX'], 'app_msg_type' => $data['APP_MSG_TYPE'], 'app_msg_subject' => $data['APP_MSG_SUBJECT'], 'app_msg_from' => $data['APP_MSG_FROM'], 'app_msg_to' => $data['APP_MSG_TO'], 'app_msg_body' => $data['APP_MSG_BODY'], 'app_msg_cc' => $data['APP_MSG_CC'], 'app_msg_bcc' => $data['APP_MSG_BCC'], 'app_msg_attach' => $data['APP_MSG_ATTACH'], 'app_msg_template' => $data['APP_MSG_TEMPLATE'], 'app_msg_status' => 'pending'
|
||||
|
||||
@@ -1106,6 +1106,9 @@ class EmailServer
|
||||
$criteria->addSelectColumn(\EmailServerPeer::MESS_TRY_SEND_INMEDIATLY);
|
||||
$criteria->addSelectColumn(\EmailServerPeer::MAIL_TO);
|
||||
$criteria->addSelectColumn(\EmailServerPeer::MESS_DEFAULT);
|
||||
$criteria->addSelectColumn(\EmailServerPeer::OAUTH_CLIENT_ID);
|
||||
$criteria->addSelectColumn(\EmailServerPeer::OAUTH_CLIENT_SECRET);
|
||||
$criteria->addSelectColumn(\EmailServerPeer::OAUTH_REFRESH_TOKEN);
|
||||
|
||||
return $criteria;
|
||||
} catch (Exception $e) {
|
||||
@@ -1143,7 +1146,10 @@ class EmailServer
|
||||
$this->getFieldNameByFormatFieldName("MESS_BACKGROUND") => '',
|
||||
$this->getFieldNameByFormatFieldName("MESS_PASSWORD_HIDDEN") => '',
|
||||
$this->getFieldNameByFormatFieldName("MESS_EXECUTE_EVERY") => '',
|
||||
$this->getFieldNameByFormatFieldName("MESS_SEND_MAX") => ''
|
||||
$this->getFieldNameByFormatFieldName("MESS_SEND_MAX") => '',
|
||||
$this->getFieldNameByFormatFieldName("OAUTH_CLIENT_ID") => $record["OAUTH_CLIENT_ID"],
|
||||
$this->getFieldNameByFormatFieldName("OAUTH_CLIENT_SECRET") => $record["OAUTH_CLIENT_SECRET"],
|
||||
$this->getFieldNameByFormatFieldName("OAUTH_REFRESH_TOKEN") => $record["OAUTH_REFRESH_TOKEN"]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
@@ -1191,6 +1197,9 @@ class EmailServer
|
||||
$arrayData["MESS_PASSWORD_HIDDEN"] = '';
|
||||
$arrayData["MESS_EXECUTE_EVERY"] = '';
|
||||
$arrayData["MESS_SEND_MAX"] = '';
|
||||
$arrayData["OAUTH_CLIENT_ID"] = $row["OAUTH_CLIENT_ID"];
|
||||
$arrayData["OAUTH_CLIENT_SECRET"] = $row["OAUTH_CLIENT_SECRET"];
|
||||
$arrayData["OAUTH_REFRESH_TOKEN"] = $row["OAUTH_REFRESH_TOKEN"];
|
||||
}
|
||||
|
||||
//Return
|
||||
|
||||
@@ -1015,7 +1015,10 @@ class System
|
||||
"MESS_BACKGROUND" => "",
|
||||
"MESS_PASSWORD_HIDDEN" => "",
|
||||
"MESS_EXECUTE_EVERY" => "",
|
||||
"MESS_SEND_MAX" => ""
|
||||
"MESS_SEND_MAX" => "",
|
||||
"OAUTH_CLIENT_ID" => $arrayEmailServerDefault["OAUTH_CLIENT_ID"],
|
||||
"OAUTH_CLIENT_SECRET" => $arrayEmailServerDefault["OAUTH_CLIENT_SECRET"],
|
||||
"OAUTH_REFRESH_TOKEN" => $arrayEmailServerDefault["OAUTH_REFRESH_TOKEN"]
|
||||
);
|
||||
|
||||
//Return
|
||||
|
||||
@@ -31,7 +31,10 @@ class EmailServerModel extends Model
|
||||
'EMAIL_SERVER.SMTPSECURE',
|
||||
'EMAIL_SERVER.MESS_TRY_SEND_INMEDIATLY',
|
||||
'EMAIL_SERVER.MAIL_TO',
|
||||
'EMAIL_SERVER.MESS_DEFAULT'
|
||||
'EMAIL_SERVER.MESS_DEFAULT',
|
||||
'EMAIL_SERVER.OAUTH_CLIENT_ID',
|
||||
'EMAIL_SERVER.OAUTH_CLIENT_SECRET',
|
||||
'EMAIL_SERVER.OAUTH_REFRESH_TOKEN'
|
||||
];
|
||||
$query = EmailServerModel::query()->select($selectedColumns);
|
||||
$query->where('EMAIL_SERVER.MESS_UID', '=', $messUid);
|
||||
@@ -64,7 +67,10 @@ class EmailServerModel extends Model
|
||||
'EMAIL_SERVER.SMTPSECURE',
|
||||
'EMAIL_SERVER.MESS_TRY_SEND_INMEDIATLY',
|
||||
'EMAIL_SERVER.MAIL_TO',
|
||||
'EMAIL_SERVER.MESS_DEFAULT'
|
||||
'EMAIL_SERVER.MESS_DEFAULT',
|
||||
'EMAIL_SERVER.OAUTH_CLIENT_ID',
|
||||
'EMAIL_SERVER.OAUTH_CLIENT_SECRET',
|
||||
'EMAIL_SERVER.OAUTH_REFRESH_TOKEN'
|
||||
];
|
||||
$query = EmailServerModel::query()->select($selectedColumns)
|
||||
->where('MESS_DEFAULT', '=', 1);
|
||||
|
||||
Reference in New Issue
Block a user