diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 1df1ee37122..c30b1d6e27e 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -877,7 +877,7 @@ class CMailFile
}
} elseif ($this->sendmode == 'smtps') {
if (!is_object($this->smtps)) {
- $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."
Constructor of object CMailFile was not initialized without errors.";
+ $this->error = "Failed to send mail with smtps lib
Constructor of object CMailFile was not initialized without errors.";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
return false;
}
@@ -895,7 +895,7 @@ class CMailFile
}
// If we use SSL/TLS
- $server = $conf->global->$keyforsmtpserver;
+ $server = getDolGlobalString($keyforsmtpserver);
$secure = '';
if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) {
$secure = 'ssl';
@@ -905,7 +905,7 @@ class CMailFile
}
$server = ($secure ? $secure.'://' : '').$server;
- $port = $conf->global->$keyforsmtpport;
+ $port = getDolGlobalInt($keyforsmtpport);
$this->smtps->setHost($server);
$this->smtps->setPort($port); // 25, 465...;
@@ -922,6 +922,8 @@ class CMailFile
}
if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
+ $supportedoauth2array = array();
+
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
$keyforsupportedoauth2array = $conf->global->$keyforsmtpoauthservice;
@@ -933,7 +935,7 @@ class CMailFile
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
- if (isset($supportedoauth2array)) {
+ if (!empty($supportedoauth2array)) {
$OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
} else {
$OAUTH_SERVICENAME = 'Unknown';
@@ -1075,6 +1077,8 @@ class CMailFile
$this->transport->setPassword($conf->global->$keyforsmtppw);
}
if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
+ $supportedoauth2array = array();
+
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
$keyforsupportedoauth2array = getDolGlobalString($keyforsmtpoauthservice);