diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 9af4c15e0a6..d482322a054 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -728,12 +728,13 @@ else // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->trackid=(($action == 'testhtml')?"testhtml":"test"); $formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->fromid=$user->id; - $formmail->trackid=(($action == 'testhtml')?"testhtml":"test"); - $formmail->withfromreadonly=1; + $formmail->fromalsorobot=1; $formmail->fromtype=(GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); + $formmail->withfromreadonly=1; $formmail->withsubstit=0; $formmail->withfrom=1; $formmail->witherrorsto=1; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 05529b3fe5f..24dd771404f 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -472,6 +472,19 @@ class FormMail extends Form // Add also email aliases if there is some $listaliases=array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); + // Also add robot email + if (! empty($this->fromalsorobot)) + { + if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) + { + $liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM; + if ($this->frommail) + { + $liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; + } + } + } + // Add also email aliases from the c_email_senderprofile table $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1 ORDER BY position'; $resql = $this->db->query($sql); @@ -491,16 +504,6 @@ class FormMail extends Form } else dol_print_error($this->db); - // Also add robot email - if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) - { - $liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM; - if ($this->frommail) - { - $liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; - } - } - foreach($listaliases as $typealias => $listalias) { $posalias=0;