diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index f751711288c..8c81c0efc6a 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -146,9 +146,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $sendtocc=''; $sendtobcc=''; $sendtoid = array(); - if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { - $sendtouserid=array(); - } + $sendtouserid=array(); + $sendtoccuserid=array(); // Define $sendto $receiver=$_POST['receiver']; @@ -179,18 +178,20 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } - if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) + { $receiveruser=$_POST['receiveruser']; if (is_array($receiveruser) && count($receiveruser)>0) { $fuserdest = new User($db); foreach($receiveruser as $key=>$val) { - $tmparray[] = $fuserdest->user_get_property($key,'email'); - $sendtouserid[] = $key; + $tmparray[] = $fuserdest->user_get_property($val,'email'); + $sendtouserid[] = $val; } } } + $sendto=implode(',',$tmparray); // Define $sendtocc @@ -222,15 +223,15 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { - $receiveruser=$_POST['receiveccruser']; + $receiverccuser=$_POST['receiverccuser']; - if (is_array($receiveruser) && count($receiveruser)>0) + if (is_array($receiverccuser) && count($receiverccuser)>0) { $fuserdest = new User($db); - foreach($receiveruser as $key=>$val) + foreach($receiverccuser as $key=>$val) { - $tmparray[] = $fuserdest->user_get_property($key,'email'); - $sendtouserid[] = $key; + $tmparray[] = $fuserdest->user_get_property($val,'email'); + $sendtoccuserid[] = $val; } } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 555ad503693..5beae12a4fb 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -632,7 +632,7 @@ class FormMail extends Form if (! empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $out.= '