diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 1c59d1bb26d..515357df904 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -562,9 +562,9 @@ if ($action == 'edit') {
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
// Force e-mail recipient
- print '
| '.$langs->trans("MAIN_MAIL_FORCE_SENDTO").' | '.$conf->global->MAIN_MAIL_FORCE_SENDTO;
- if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) {
- if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) {
+ print ' |
| '.$langs->trans("MAIN_MAIL_FORCE_SENDTO").' | '.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO');
+ if (!empty(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
+ if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) {
print img_warning($langs->trans("ErrorBadEMail"));
} else {
print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index e3a218711dd..5151a0a39dc 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -41,6 +41,29 @@
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
+/**
+ * Return dolibarr global constant string value
+ * @param string $key key to return value, return '' if not set
+ * @return string
+ */
+function getDolGlobalString($key)
+{
+ global $conf;
+ // return $conf->global->$key ?? '';
+ return (string) (empty($conf->global->$key) ? '' : $conf->global->$key);
+}
+
+/**
+ * Return dolibarr global constant int value
+ * @param string $key key to return value, return 0 if not set
+ * @return int
+ */
+function getDolGlobalInt($key)
+{
+ global $conf;
+ // return $conf->global->$key ?? 0;
+ return (int) (empty($conf->global->$key) ? 0 : $conf->global->$key);
+}
/**
* Return a DoliDB instance (database handler).
|