diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index d482322a054..677e6099a8d 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -70,6 +70,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs);
if ($action == 'update' && empty($_POST["cancel"]))
{
dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity);
// Send mode parameters
dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity);
@@ -238,6 +239,11 @@ if ($action == 'edit')
print '
| '.$langs->trans("MAIN_DISABLE_ALL_MAILS").' | ';
print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1);
print ' |
';
+
+ // Force e-mail recipient
+ print '| '.$langs->trans("MAIN_MAIL_FORCE_SENDTO").' | ';
+ print '';
+ print ' |
';
// Separator
@@ -477,6 +483,11 @@ else
// Disable
print '| '.$langs->trans("MAIN_DISABLE_ALL_MAILS").' | '.yn($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) && ! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail"));
+ print ' |
';
// Separator
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 86a6cb008d3..c79b7ac0cea 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -495,7 +495,7 @@ class CMailFile
$res=false;
- if (empty($conf->global->MAIN_DISABLE_ALL_MAILS))
+ if (empty($conf->global->MAIN_DISABLE_ALL_MAILS) || !empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
{
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
@@ -557,6 +557,12 @@ class CMailFile
$keyfortls ='MAIN_MAIL_EMAIL_TLS_EMAILING';
$keyforstarttls ='MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
}
+
+ if(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) {
+ $this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO;
+ $this->addr_cc = '';
+ $this->addr_bcc = '';
+ }
// Action according to choosed sending method
if ($this->sendmode == 'mail')