PMCORE-2948-A Update the branch develop with the release/3.5.11
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use PHPMailer\PHPMailer\OAuth;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use ProcessMaker\Core\System;
|
||||
|
||||
/**
|
||||
@@ -519,18 +521,18 @@ class SpoolRun
|
||||
case 'PHPMAILER':
|
||||
case 'IMAP':
|
||||
case 'GMAILAPI':
|
||||
case 'OFFICE365API':
|
||||
$phpMailer = new PHPMailer();
|
||||
switch ($this->config['MESS_ENGINE']) {
|
||||
case 'MAIL':
|
||||
$phpMailer = new PHPMailer();
|
||||
$phpMailer->Mailer = 'mail';
|
||||
break;
|
||||
case 'IMAP':
|
||||
case 'PHPMAILER':
|
||||
$phpMailer = new PHPMailer(true);
|
||||
$phpMailer->Mailer = 'smtp';
|
||||
break;
|
||||
case 'GMAILAPI':
|
||||
$phpMailer = new PHPMailerOAuth();
|
||||
case 'OFFICE365API':
|
||||
$phpMailer->AuthType = 'XOAUTH2';
|
||||
$phpMailer->isSMTP();
|
||||
break;
|
||||
@@ -544,6 +546,7 @@ class SpoolRun
|
||||
case 'IMAP':
|
||||
case 'PHPMAILER':
|
||||
case 'GMAILAPI':
|
||||
case 'OFFICE365API':
|
||||
//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'];
|
||||
@@ -558,14 +561,42 @@ class SpoolRun
|
||||
$phpMailer->Encoding = "8bit";
|
||||
$phpMailer->Host = $this->config['MESS_SERVER'];
|
||||
$phpMailer->Port = $this->config['MESS_PORT'];
|
||||
if ($this->config['MESS_ENGINE'] !== 'GMAILAPI') {
|
||||
if (!in_array($this->config['MESS_ENGINE'], ['GMAILAPI', 'OFFICE365API'])) {
|
||||
$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'];
|
||||
// Get provider
|
||||
switch ($this->config['MESS_ENGINE']) {
|
||||
case 'GMAILAPI':
|
||||
$providerClass = '\League\OAuth2\Client\Provider\Google';
|
||||
break;
|
||||
case 'OFFICE365API':
|
||||
$providerClass = '\Stevenmaguire\OAuth2\Client\Provider\Microsoft';
|
||||
break;
|
||||
default:
|
||||
throw new Exception('Only Google and Microsoft OAuth2 providers are currently supported.');
|
||||
break;
|
||||
}
|
||||
$provider = new $providerClass(
|
||||
[
|
||||
'clientId' => $this->config['OAUTH_CLIENT_ID'],
|
||||
'clientSecret' => $this->config['OAUTH_CLIENT_SECRET'],
|
||||
'accessType' => 'offline'
|
||||
]
|
||||
);
|
||||
|
||||
// Set OAuth to use
|
||||
$phpMailer->setOAuth(
|
||||
new OAuth(
|
||||
[
|
||||
'provider' => $provider,
|
||||
'clientId' => $this->config['OAUTH_CLIENT_ID'],
|
||||
'clientSecret' => $this->config['OAUTH_CLIENT_SECRET'],
|
||||
'refreshToken' => $this->config['OAUTH_REFRESH_TOKEN'],
|
||||
'userName' => $this->config['MESS_ACCOUNT']
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//From
|
||||
|
||||
Reference in New Issue
Block a user